logtail: print panics from previous runs on stderr

Signed-off-by: David Crawshaw <crawshaw@tailscale.com>
pull/2502/head
David Crawshaw 3 years ago committed by Josh Bleecher Snyder
parent 3e039daf95
commit 1606ef5219

@ -118,6 +118,7 @@ type Logger struct {
bo *backoff.Backoff bo *backoff.Backoff
zstdEncoder Encoder zstdEncoder Encoder
uploadCancel func() uploadCancel func()
explainedRaw bool
shutdownStart chan struct{} // closed when shutdown begins shutdownStart chan struct{} // closed when shutdown begins
shutdownDone chan struct{} // closd when shutdown complete shutdownDone chan struct{} // closd when shutdown complete
@ -230,6 +231,14 @@ func (l *Logger) drainPending() (res []byte) {
// outside of the logtail logger. Encode it. // outside of the logtail logger. Encode it.
// Do not add a client time, as it could have been // Do not add a client time, as it could have been
// been written a long time ago. // been written a long time ago.
if !l.explainedRaw {
fmt.Fprintf(l.stderr, "RAW-STDERR: ***\n")
fmt.Fprintf(l.stderr, "RAW-STDERR: *** Lines prefixed with RAW-STDERR below bypassed logtail and probably come from a previous run of the program\n")
fmt.Fprintf(l.stderr, "RAW-STDERR: ***\n")
fmt.Fprintf(l.stderr, "RAW-STDERR:\n")
l.explainedRaw = true
}
fmt.Fprintf(l.stderr, "RAW-STDERR: %s", b)
b = l.encodeText(b, true) b = l.encodeText(b, true)
} }

Loading…
Cancel
Save