diff options
author | Robin Jarry <robin@jarry.cc> | 2022-08-12 12:24:52 +0200 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2022-08-22 15:46:33 +0200 |
commit | d7e6dc3649eadc27bdfdac77785b6bbf77d30b79 (patch) | |
tree | fcd3eebf66f7ac3264b06dc584f0c5c09f716028 /logging | |
parent | 45e506e6aebdfdcb743d2d861eaddb85a01b3d5b (diff) | |
download | aerc-d7e6dc3649eadc27bdfdac77785b6bbf77d30b79.tar.gz |
aerc: add build info to version string
Example:
$ aerc -v
aerc 0.11.0 +notmuch (go1.18.4 amd64 linux)
Also include that version information in the debug and panic logs.
debug.ReadBuildInfo() is only available in go 1.18+. Add a new variable
set at build time to store $GOFLAGS.
Suggested-by: Tim Culverhouse <tim@timculverhouse.com>
Signed-off-by: Robin Jarry <robin@jarry.cc>
Acked-by: Moritz Poldrack <moritz@poldrack.dev>
Diffstat (limited to 'logging')
-rw-r--r-- | logging/panic-logger.go | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/logging/panic-logger.go b/logging/panic-logger.go index 9f57f650..11b1803e 100644 --- a/logging/panic-logger.go +++ b/logging/panic-logger.go @@ -9,7 +9,10 @@ import ( "time" ) -var UICleanup = func() {} +var ( + UICleanup = func() {} + BuildInfo string +) // PanicHandler tries to restore the terminal. A stack trace is written to // aerc-crash.log and then passed on if a panic occurs. @@ -41,6 +44,7 @@ func PanicHandler() { fmt.Fprintln(panicLog, time.Now().Format("2006-01-02T15:04:05.000000-0700")) fmt.Fprintln(panicLog, strings.Repeat("#", 80)) fmt.Fprintf(outputs, "%s\n", panicMessage) + fmt.Fprintf(outputs, "Version: %s\n", BuildInfo) fmt.Fprintf(panicLog, "Error: %v\n\n", r) panicLog.Write(debug.Stack()) //nolint:errcheck // we are already in a panic, so not much we can do here fmt.Fprintf(os.Stderr, "\nThis error was also written to: %s\n", filename) |