From aae62ff94e79c4c5ba5f98f8f801a90529aaef4f Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Thu, 26 Jan 2017 11:44:07 +0000 Subject: [PATCH] store logs --- scripts/rageshake.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/scripts/rageshake.go b/scripts/rageshake.go index 317b94ec..6ffd1476 100644 --- a/scripts/rageshake.go +++ b/scripts/rageshake.go @@ -8,6 +8,7 @@ import ( "bytes" "compress/gzip" "encoding/json" + "fmt" "io/ioutil" "log" "net/http" @@ -83,10 +84,19 @@ func main() { // "bugreport-20170115-112233-N.log.gz" => oldest log t := time.Now() prefix := t.Format("bugreport-20060102-150405") - if err := gzipAndSave([]byte(p.Text), prefix+".log.gz"); err != nil { + summary := fmt.Sprintf( + "%s\n\nNumber of logs: %d\nVersion: %s\nUser-Agent: %s\n", p.Text, len(p.Logs), p.Version, p.UserAgent, + ) + if err := gzipAndSave([]byte(summary), prefix+".log.gz"); err != nil { respond(500, w) return } + for i, log := range p.Logs { + if err := gzipAndSave([]byte(log.Lines), fmt.Sprintf("%s-%d.log.gz", prefix, i)); err != nil { + respond(500, w) + return // TODO: Rollback? + } + } respond(200, w) })