Manager: don't log an error when the config file doesn't exist
The configuration file is expected to not exist on many systems, and thus logging an error (even when it's a very innocent one) will cause confusion.
This commit is contained in:
parent
c3cd119e21
commit
2e78e00a0b
@ -62,7 +62,7 @@ func main() {
|
|||||||
// Load configuration.
|
// Load configuration.
|
||||||
configService := config.NewService()
|
configService := config.NewService()
|
||||||
err := configService.Load()
|
err := configService.Load()
|
||||||
if err != nil {
|
if err != nil && !os.IsNotExist(err) {
|
||||||
log.Error().Err(err).Msg("loading configuration")
|
log.Error().Err(err).Msg("loading configuration")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -192,13 +192,13 @@ func loadConf(filename string) (Conf, error) {
|
|||||||
log.Info().Str("file", filename).Msg("loading configuration")
|
log.Info().Str("file", filename).Msg("loading configuration")
|
||||||
yamlFile, err := os.ReadFile(filename)
|
yamlFile, err := os.ReadFile(filename)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
var level zerolog.Level
|
var evt *zerolog.Event
|
||||||
if os.IsNotExist(err) {
|
if os.IsNotExist(err) {
|
||||||
level = zerolog.DebugLevel
|
evt = log.Debug()
|
||||||
} else {
|
} else {
|
||||||
level = zerolog.WarnLevel
|
evt = log.Warn().Err(err)
|
||||||
}
|
}
|
||||||
log.WithLevel(level).Err(err).Msg("unable to load configuration, using defaults")
|
evt.Msg("unable to load configuration, using defaults")
|
||||||
return DefaultConfig(), err
|
return DefaultConfig(), err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user