Close logfile when main() terminates

This commit is contained in:
Willy Goiffon
2020-07-07 10:14:19 +02:00
parent d931d812c2
commit 115b90ffc1

View File

@@ -51,6 +51,14 @@ func main() {
cfg := config.NewConfig(rootLogger, *flagConfig)
cfg.BridgeValues().General.Debug = *flagDebug
// if logging to a file, ensure it is closed when the program terminates
defer func() {
if f, ok := rootLogger.Out.(*os.File); ok {
f.Sync()
f.Close()
}
}()
r, err := gateway.NewRouter(rootLogger, cfg, bridgemap.FullMap)
if err != nil {
logger.Fatalf("Starting gateway failed: %s", err)