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:
Sybren A. Stüvel 2022-03-14 13:00:27 +01:00
parent c3cd119e21
commit 2e78e00a0b
2 changed files with 5 additions and 5 deletions

View File

@ -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")
} }

View File

@ -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
} }