feat(GODT-2691): close logrus output file on exit.

This commit is contained in:
Xavier Michelon
2023-06-28 13:34:19 +02:00
parent c267168cb7
commit 7b7c9093ce
5 changed files with 52 additions and 8 deletions

View File

@ -18,6 +18,7 @@
package main
import (
"io"
"os"
"path/filepath"
"runtime"
@ -81,7 +82,8 @@ func main() { //nolint:funlen
sessionID := logging.NewSessionID()
crashHandler.AddRecoveryAction(logging.DumpStackTrace(logsPath, sessionID, launcherName))
if err := logging.Init(
var closer io.Closer
if closer, err = logging.Init(
logsPath,
sessionID,
logging.LauncherShortAppName,
@ -92,6 +94,10 @@ func main() { //nolint:funlen
l.WithError(err).Fatal("Failed to setup logging")
}
defer func() {
_ = logging.Close(closer)
}()
updatesPath, err := locations.ProvideUpdatesPath()
if err != nil {
l.WithError(err).Fatal("Failed to get updates path")