weed: flush buffered log lines when a command exits (#13151)

exit() ends the process with os.Exit, which skips deferred calls, and
glog writes its files only every 30s. A short-lived command such as a
piped weed shell session lost every log line it buffered, including the
daily_run summary of s3.lifecycle.run-shard.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Chris LuandClaude Opus 5.5 authored and GitHub committed 2026-11-30 10:39:05 -08:00
1 parent edbcc718d3
commit d4a21cef59
1 file changed
+3 -1
+3 -1
View File
@@ -221,7 +221,9 @@ func exit() {
for _, f := range atexitFuncs {
f()
}
// os.Exit below skips main's deferred flush.
// os.Exit below skips main's deferred flush, and glog only flushes its
// files every 30s, so a short command would lose its log lines.
glog.Flush()
sentry.Flush(2 * time.Second)
os.Exit(exitStatus)
}