diff --git a/config.go b/config.go index d04df007..6a1cf2cf 100644 --- a/config.go +++ b/config.go @@ -89,11 +89,6 @@ func (c *Config) Load(loaders ...Loader) error { // Merged to empty map to convert to lower case. maps.Merge(provider.values, values) c.providers = append(c.providers, provider) - - slog.Info( - "Configuration has been loaded.", - "loader", loader, - ) } return nil @@ -212,7 +207,6 @@ func (c *Config) Watch(ctx context.Context) error { //nolint:cyclop,funlen,gocog ) } - slog.Info("Watching configuration change.", "loader", watcher) if err := watcher.Watch(ctx, onChange); err != nil { errChan <- fmt.Errorf("watch configuration change: %w", err) cancel() diff --git a/default.go b/default.go index 4b373d2d..6cd120b6 100644 --- a/default.go +++ b/default.go @@ -17,7 +17,7 @@ import ( func Get[T any](path string) T { //nolint:ireturn var value T if err := Unmarshal(path, &value); err != nil { - slog.Error( + slog.Warn( "Could not read config, return empty value instead.", "error", err, "path", path, diff --git a/default_test.go b/default_test.go index 06efbc2e..6603c33c 100644 --- a/default_test.go +++ b/default_test.go @@ -47,7 +47,7 @@ func TestGet_error(t *testing.T) { log.SetFlags(0) assert.True(t, !konf.Get[bool]("config")) - expected := "ERROR Could not read config, return empty value instead." + + expected := "WARN Could not read config, return empty value instead." + " error=\"decode: cannot parse '' as bool: strconv.ParseBool: parsing \\\"string\\\": invalid syntax\"" + " path=config type=bool\n" assert.Equal(t, expected, buf.String()) diff --git a/provider/file/watch.go b/provider/file/watch.go index 106e744e..2fd9a308 100644 --- a/provider/file/watch.go +++ b/provider/file/watch.go @@ -21,7 +21,7 @@ func (f File) Watch(ctx context.Context, onChange func(map[string]any)) error { } defer func() { if err := watcher.Close(); err != nil { - slog.Error("Error when closing file watcher.", "file", f.path, "error", err) + slog.WarnContext(ctx, "Error when closing file watcher.", "file", f.path, "error", err) } }() @@ -73,7 +73,7 @@ func (f File) Watch(ctx context.Context, onChange func(map[string]any)) error { case event.Has(fsnotify.Create) || event.Has(fsnotify.Write): values, err := f.Load() if err != nil { - slog.Error("Error when reloading config file", "file", f.path, "error", err) + slog.WarnContext(ctx, "Error when reloading config file", "file", f.path, "error", err) continue } @@ -85,7 +85,7 @@ func (f File) Watch(ctx context.Context, onChange func(map[string]any)) error { return nil } - slog.Error("Error when watching file", "file", f.path, "error", err) + slog.WarnContext(ctx, "Error when watching file", "file", f.path, "error", err) case <-ctx.Done(): return nil