Warn when Koanf read fails #47
@ -1,7 +1,6 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
@ -68,7 +67,7 @@ func loadAndwatchCfgFile(filename string) {
|
|||||||
provider := file.Provider(filename)
|
provider := file.Provider(filename)
|
||||||
|
|
||||||
if cfgError := k.Load(provider, toml.Parser()); cfgError != nil {
|
if cfgError := k.Load(provider, toml.Parser()); cfgError != nil {
|
||||||
log.Warn().Msg(fmt.Sprintf("Error while trying to read %s: %s\n", filename, cfgError.Error()))
|
log.Warn().Str("filename", filename).Err(cfgError).Msg("Error while trying to read config file")
|
||||||
}
|
}
|
||||||
Hunman marked this conversation as resolved
Elara6331
commented
Review
```diff
- log.Warn().Msg(fmt.Sprintf("Error while trying to read %s: %s\n", filename, cfgError.Error()))
+ log.Warn().Str("filename", filename).Err(cfgError).Msg("Error while trying to read config file")
```
|
|||||||
|
|
||||||
// Watch for changes and reload when detected
|
// Watch for changes and reload when detected
|
||||||
@ -78,7 +77,7 @@ func loadAndwatchCfgFile(filename string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if cfgError := k.Load(provider, toml.Parser()); cfgError != nil {
|
if cfgError := k.Load(provider, toml.Parser()); cfgError != nil {
|
||||||
log.Warn().Msg(fmt.Sprintf("Error while trying to read %s: %s\n", filename, cfgError.Error()))
|
log.Warn().Str("filename", filename).Err(cfgError).Msg("Error while trying to read config file")
|
||||||
}
|
}
|
||||||
Hunman marked this conversation as resolved
Elara6331
commented
Same as above
Same as above
```diff
- log.Warn().Msg(fmt.Sprintf("Error while trying to read %s: %s\n", filename, cfgError.Error()))
+ log.Warn().Str("filename", filename).Err(cfgError).Msg("Error while trying to read config file")
```
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user