1
0
Fork 0
mirror of https://github.com/chainguard-dev/clog synced 2026-07-06 22:12:46 +00:00

Fix handler example to actually use the handler. (#4)

This commit is contained in:
Billy Lynch 2024-01-16 11:15:36 -05:00 committed by GitHub
parent 988f6253cd
commit c071a43a42
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -10,17 +10,17 @@ import (
)
func ExampleHandler() {
log := slog.New(slog.NewTextHandler(os.Stdout, &slog.HandlerOptions{
log := slog.New(slogctx.NewHandler(slog.NewTextHandler(os.Stdout, &slog.HandlerOptions{
// Remove time for repeatable results
ReplaceAttr: slogtest.RemoveTime,
}))
})))
ctx := context.Background()
ctx = slogctx.WithValues(ctx, "foo", "bar")
log.InfoContext(ctx, "hello world", slog.Bool("baz", true))
// Output:
// level=INFO msg="hello world" baz=true
// level=INFO msg="hello world" baz=true foo=bar
}
func ExampleLogger() {