Don't open log file if file name format is unset

This commit is contained in:
Tulir Asokan 2019-08-24 22:45:16 +03:00
parent 80a0edd855
commit 18724cde6e

View file

@ -112,20 +112,22 @@ 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)
if len(bridge.Config.Logging.FileNameFormat) > 0 {
err = log.OpenFile()
if err != nil {
fmt.Fprintln(os.Stderr, "Failed to open log file:", err)
_, _ = fmt.Fprintln(os.Stderr, "Failed to open log file:", err)
os.Exit(12)
}
}
bridge.AS.Log = log.Sub("Matrix")
bridge.Log.Debugln("Initializing state store")