Skip to content

Commit 398e112

Browse files
committed
slog-handler-guide: warn against embedding
For golang/go#73057. Change-Id: Id9ee1c0af03f9b49f6063aa946b6fe5cfbc02483 Reviewed-on: https://go-review.googlesource.com/c/example/+/660956 LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]>
1 parent 40afcb7 commit 398e112

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

slog-handler-guide/guide.md

+5
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,11 @@ so it will sometimes produce invalid YAML.
9494
For example, it doesn't quote keys that have colons in them.
9595
We'll call it `IndentHandler` to forestall disappointment.
9696

97+
A brief aside before we start: it is tempting to embed `slog.Handler` in your
98+
custom handler and implement only the methods that you need.
99+
Loggers and handlers are too tightly coupled for that to work. You should
100+
implement all four handler methods.
101+
97102
We begin with the `IndentHandler` type
98103
and the `New` function that constructs it from an `io.Writer` and options:
99104

0 commit comments

Comments
 (0)