From 53cdb5253a20be742fe6ca7008f58beda1a99c34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rk=20S=C3=A1gi-Kaz=C3=A1r?= Date: Mon, 29 May 2023 15:31:29 +0200 Subject: [PATCH] chore: improve log messages --- viper.go | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/viper.go b/viper.go index 20ff23f..7fb1e19 100644 --- a/viper.go +++ b/viper.go @@ -440,16 +440,14 @@ func (v *Viper) WatchConfig() { go func() { watcher, err := newWatcher() if err != nil { - v.logger.Error("failure to create watcher", - "msg", err.Error()) + v.logger.Error(fmt.Sprintf("failed to create watcher: %s", err)) os.Exit(1) } defer watcher.Close() // we have to watch the entire directory to pick up renames/atomic saves in a cross-platform way filename, err := v.getConfigFile() if err != nil { - v.logger.Error("get config file", - "msg", err.Error()) + v.logger.Error(fmt.Sprintf("get config file: %s", err)) initWG.Done() return } @@ -478,8 +476,7 @@ func (v *Viper) WatchConfig() { realConfigFile = currentConfigFile err := v.ReadInConfig() if err != nil { - v.logger.Error("reading config file", - "msg", err.Error()) + v.logger.Error(fmt.Sprintf("read config file: %s", err)) } if v.onConfigChange != nil { v.onConfigChange(event) @@ -491,7 +488,7 @@ func (v *Viper) WatchConfig() { case err, ok := <-watcher.Errors: if ok { // 'Errors' channel is not closed - v.logger.Error("watcher error", "msg", err.Error()) + v.logger.Error(fmt.Sprintf("watcher error: %s", err)) } eventsWG.Done() return