mirror of
https://github.com/SchildiChat/element-web.git
synced 2024-10-01 01:26:12 -04:00
store logs
This commit is contained in:
parent
e8c51a0b54
commit
aae62ff94e
@ -8,6 +8,7 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"compress/gzip"
|
"compress/gzip"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
@ -83,10 +84,19 @@ func main() {
|
|||||||
// "bugreport-20170115-112233-N.log.gz" => oldest log
|
// "bugreport-20170115-112233-N.log.gz" => oldest log
|
||||||
t := time.Now()
|
t := time.Now()
|
||||||
prefix := t.Format("bugreport-20060102-150405")
|
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)
|
respond(500, w)
|
||||||
return
|
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)
|
respond(200, w)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user