mirror of
https://github.com/spf13/viper
synced 2024-11-04 20:27:02 +00:00
chore: improve log messages
This commit is contained in:
parent
24ece16a9a
commit
53cdb5253a
1 changed files with 4 additions and 7 deletions
11
viper.go
11
viper.go
|
@ -440,16 +440,14 @@ func (v *Viper) WatchConfig() {
|
||||||
go func() {
|
go func() {
|
||||||
watcher, err := newWatcher()
|
watcher, err := newWatcher()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
v.logger.Error("failure to create watcher",
|
v.logger.Error(fmt.Sprintf("failed to create watcher: %s", err))
|
||||||
"msg", err.Error())
|
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
defer watcher.Close()
|
defer watcher.Close()
|
||||||
// we have to watch the entire directory to pick up renames/atomic saves in a cross-platform way
|
// we have to watch the entire directory to pick up renames/atomic saves in a cross-platform way
|
||||||
filename, err := v.getConfigFile()
|
filename, err := v.getConfigFile()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
v.logger.Error("get config file",
|
v.logger.Error(fmt.Sprintf("get config file: %s", err))
|
||||||
"msg", err.Error())
|
|
||||||
initWG.Done()
|
initWG.Done()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -478,8 +476,7 @@ func (v *Viper) WatchConfig() {
|
||||||
realConfigFile = currentConfigFile
|
realConfigFile = currentConfigFile
|
||||||
err := v.ReadInConfig()
|
err := v.ReadInConfig()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
v.logger.Error("reading config file",
|
v.logger.Error(fmt.Sprintf("read config file: %s", err))
|
||||||
"msg", err.Error())
|
|
||||||
}
|
}
|
||||||
if v.onConfigChange != nil {
|
if v.onConfigChange != nil {
|
||||||
v.onConfigChange(event)
|
v.onConfigChange(event)
|
||||||
|
@ -491,7 +488,7 @@ func (v *Viper) WatchConfig() {
|
||||||
|
|
||||||
case err, ok := <-watcher.Errors:
|
case err, ok := <-watcher.Errors:
|
||||||
if ok { // 'Errors' channel is not closed
|
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()
|
eventsWG.Done()
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in a new issue