Skip to content

Commit 0d63173

Browse files
committed
slog: clarify the responsibilities of Handler methods
Change-Id: I2c302b3af61965387fbc927937fd98dc1dcbb0fc Reviewed-on: https://go-review.googlesource.com/c/exp/+/429840 Run-TryBot: Jonathan Amsterdam <[email protected]> Reviewed-by: Alan Donovan <[email protected]> TryBot-Result: Gopher Robot <[email protected]>
1 parent 259cd2c commit 0d63173

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

slog/handler.go

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,25 @@ import (
1515
"golang.org/x/exp/slog/internal/buffer"
1616
)
1717

18-
// A Handler processes log records produced by Logger output.
18+
// A Handler handles log records produced by a Logger..
19+
//
20+
// A typical handler may print log records to standard error,
21+
// or write them to a file or database, or perhaps augment them
22+
// with additional attributes and pass them on to another handler.
23+
//
1924
// Any of the Handler's methods may be called concurrently with itself
2025
// or with other methods. It is the responsibility of the Handler to
2126
// manage this concurrency.
2227
type Handler interface {
23-
// Enabled reports whether this handler is accepting records
24-
// at the given level.
28+
// Enabled reports whether the handler handles records at the given level.
29+
// The handler ignores records whose level is lower.
2530
Enabled(Level) bool
2631

27-
// Handle processes the Record.
32+
// Handle handles the Record.
2833
// Handle methods that produce output should observe the following rules:
29-
// - If r.Time() is the zero time, do not output the time.
30-
// - If r.Level() is Level(0), do not output the level.
31-
// - If an Attr's key is the empty string, do not output the Attr.
34+
// - If r.Time() is the zero time, ignore the time.
35+
// - If r.Level() is Level(0), ignore the level.
36+
// - If an Attr's key is the empty string, ignore the Attr.
3237
Handle(r Record) error
3338

3439
// With returns a new Handler whose attributes consist of

0 commit comments

Comments
 (0)