From 18724cde6e78591f2fb25feab2c5c29cd81c6d5c Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Sat, 24 Aug 2019 22:45:16 +0300 Subject: [PATCH] Don't open log file if file name format is unset --- main.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/main.go b/main.go index 9b0eb9e..508653a 100644 --- a/main.go +++ b/main.go @@ -112,19 +112,21 @@ func (bridge *Bridge) Init() { bridge.AS, err = bridge.Config.MakeAppService() if err != nil { - fmt.Fprintln(os.Stderr, "Failed to initialize AppService:", err) + _, _ = fmt.Fprintln(os.Stderr, "Failed to initialize AppService:", err) os.Exit(11) } - bridge.AS.Init() + _, _ = bridge.AS.Init() bridge.Bot = bridge.AS.BotIntent() bridge.Log = log.Create() bridge.Config.Logging.Configure(bridge.Log) log.DefaultLogger = bridge.Log.(*log.BasicLogger) - err = log.OpenFile() - if err != nil { - fmt.Fprintln(os.Stderr, "Failed to open log file:", err) - os.Exit(12) + if len(bridge.Config.Logging.FileNameFormat) > 0 { + err = log.OpenFile() + if err != nil { + _, _ = fmt.Fprintln(os.Stderr, "Failed to open log file:", err) + os.Exit(12) + } } bridge.AS.Log = log.Sub("Matrix")