Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

revise log #83

Merged
merged 1 commit into from
Feb 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion default.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion default_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
6 changes: 3 additions & 3 deletions provider/file/watch.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}()

Expand Down Expand Up @@ -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
}
Expand All @@ -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
Expand Down
Loading