Check f.Sync() errors before closing logfile

This commit is contained in:
Willy Goiffon
2020-07-08 11:26:05 +02:00
parent 115b90ffc1
commit f3919db8c4

View File

@@ -54,8 +54,9 @@ func main() {
// if logging to a file, ensure it is closed when the program terminates // if logging to a file, ensure it is closed when the program terminates
defer func() { defer func() {
if f, ok := rootLogger.Out.(*os.File); ok { if f, ok := rootLogger.Out.(*os.File); ok {
f.Sync() if err := f.Sync(); err != nil {
f.Close() f.Close()
}
} }
}() }()