Skip to content

Commit

Permalink
chore: improve log messages
Browse files Browse the repository at this point in the history
  • Loading branch information
sagikazarmark committed May 29, 2023
1 parent 24ece16 commit 53cdb52
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions viper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down

0 comments on commit 53cdb52

Please sign in to comment.