Skip to content

Commit

Permalink
slogtest: include debug logs by default (#23)
Browse files Browse the repository at this point in the history
#13 (comment)

Signed-off-by: Jason Hall <jason@chainguard.dev>
  • Loading branch information
imjasonh authored Aug 9, 2024
1 parent 56a6d5a commit d36bc96
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions slogtest/slogtest.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ type Logger interface{ Log(args ...any) }
// This logger is configured to log at debug level.
func TestLogger(t Logger) *clog.Logger {
return clog.New(slog.NewTextHandler(&logAdapter{l: t}, &slog.HandlerOptions{
Level: slog.LevelDebug,
AddSource: true,
ReplaceAttr: RemoveTime,
}))
Expand Down
5 changes: 5 additions & 0 deletions slogtest/slogtest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,9 @@ func TestSlogTest(t *testing.T) {
clog.FromContext(ctx).With("foo", "bar").Infof("hello world")
clog.FromContext(ctx).With("bar", "baz").Infof("me again")
clog.FromContext(ctx).With("baz", true).Infof("okay last one")

clog.FromContext(ctx).Debug("hello debug")
clog.FromContext(ctx).Info("hello info")
clog.FromContext(ctx).Warn("hello warn")
clog.FromContext(ctx).Error("hello error")
}

0 comments on commit d36bc96

Please sign in to comment.