Skip to content

Commit

Permalink
default client: Use inner handler for log level enabled check. (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
wlynch authored Jan 27, 2025
1 parent 7b8abfe commit 479d629
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func (h Handler) inner() slog.Handler {
}

func (h Handler) Enabled(ctx context.Context, level slog.Level) bool {
return true
return h.inner().Enabled(ctx, level)
}

func (h Handler) Handle(ctx context.Context, r slog.Record) error {
Expand Down
11 changes: 11 additions & 0 deletions logger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,4 +175,15 @@ func TestDefaultHandler(t *testing.T) {
t.Errorf("want %v, got %v", want, got)
}
})

b.Reset()

t.Run("Debug - no log", func(t *testing.T) {
logger := FromContext(context.Background())
logger.Debug("asdf")

if b.Len() != 0 {
t.Errorf("want empty, got %q", b.String())
}
})
}

0 comments on commit 479d629

Please sign in to comment.