Slightly improve panic log format (...)
- Don't repeat the first log lines - Print panic timestamp in context.
This commit is contained in:
parent
828bbc407f
commit
e9d27b9d2b
@ -153,7 +153,6 @@ func copyStderr(stderr io.ReadCloser) {
|
|||||||
l.Warnf("Panic detected, writing to \"%s\"", panicFd.Name())
|
l.Warnf("Panic detected, writing to \"%s\"", panicFd.Name())
|
||||||
l.Warnln("Please create an issue at https://github.com/syncthing/syncthing/issues/ with the panic log attached")
|
l.Warnln("Please create an issue at https://github.com/syncthing/syncthing/issues/ with the panic log attached")
|
||||||
|
|
||||||
panicFd.WriteString("Panic at " + time.Now().Format(time.RFC1123) + "\n")
|
|
||||||
stdoutMut.Lock()
|
stdoutMut.Lock()
|
||||||
for _, line := range stdoutFirstLines {
|
for _, line := range stdoutFirstLines {
|
||||||
panicFd.WriteString(line)
|
panicFd.WriteString(line)
|
||||||
@ -163,6 +162,8 @@ func copyStderr(stderr io.ReadCloser) {
|
|||||||
panicFd.WriteString(line)
|
panicFd.WriteString(line)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
panicFd.WriteString("Panic at " + time.Now().Format(time.RFC3339) + "\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
if panicFd != nil {
|
if panicFd != nil {
|
||||||
@ -182,11 +183,12 @@ func copyStdout(stderr io.ReadCloser) {
|
|||||||
stdoutMut.Lock()
|
stdoutMut.Lock()
|
||||||
if len(stdoutFirstLines) < cap(stdoutFirstLines) {
|
if len(stdoutFirstLines) < cap(stdoutFirstLines) {
|
||||||
stdoutFirstLines = append(stdoutFirstLines, line)
|
stdoutFirstLines = append(stdoutFirstLines, line)
|
||||||
|
} else {
|
||||||
|
if l := len(stdoutLastLines); l == cap(stdoutLastLines) {
|
||||||
|
stdoutLastLines = stdoutLastLines[:l-1]
|
||||||
|
}
|
||||||
|
stdoutLastLines = append(stdoutLastLines, line)
|
||||||
}
|
}
|
||||||
if l := len(stdoutLastLines); l == cap(stdoutLastLines) {
|
|
||||||
stdoutLastLines = stdoutLastLines[:l-1]
|
|
||||||
}
|
|
||||||
stdoutLastLines = append(stdoutLastLines, line)
|
|
||||||
stdoutMut.Unlock()
|
stdoutMut.Unlock()
|
||||||
|
|
||||||
os.Stdout.WriteString(line)
|
os.Stdout.WriteString(line)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user