From f3919db8c4f603c220ad98c056ff422caa747b99 Mon Sep 17 00:00:00 2001 From: Willy Goiffon Date: Wed, 8 Jul 2020 11:26:05 +0200 Subject: [PATCH] Check f.Sync() errors before closing logfile --- matterbridge.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/matterbridge.go b/matterbridge.go index 145ce68c..6d40e423 100644 --- a/matterbridge.go +++ b/matterbridge.go @@ -54,8 +54,9 @@ func main() { // 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() + if err := f.Sync(); err != nil { + f.Close() + } } }()