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 <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
diff --git a/slog-handler-guide/guide.md b/slog-handler-guide/guide.md index b79b5e2..4207e7a 100644 --- a/slog-handler-guide/guide.md +++ b/slog-handler-guide/guide.md
@@ -94,6 +94,11 @@ For example, it doesn't quote keys that have colons in them. We'll call it `IndentHandler` to forestall disappointment. +A brief aside before we start: it is tempting to embed `slog.Handler` in your +custom handler and implement only the methods that you need. +Loggers and handlers are too tightly coupled for that to work. You should +implement all four handler methods. + We begin with the `IndentHandler` type and the `New` function that constructs it from an `io.Writer` and options: