slog-handler-guide: fix link, mention ReplaceAttr - Fix a broken link. - When discussing handler options, mention ReplaceAttr. This were both suggested by Peter Aronoff (peteraronoff@fastmail.com) in a direct email. Change-Id: I286142a1c5736691e32042e383f9a98e78f0fb49 Reviewed-on: https://go-review.googlesource.com/c/example/+/524758 Commit-Queue: Jonathan Amsterdam <jba@google.com> Reviewed-by: Alan Donovan <adonovan@google.com> TryBot-Bypass: Jonathan Amsterdam <jba@google.com>
diff --git a/slog-handler-guide/README.md b/slog-handler-guide/README.md index 89b6109..712ec12 100644 --- a/slog-handler-guide/README.md +++ b/slog-handler-guide/README.md
@@ -147,6 +147,12 @@ will change the behavior of all handlers that contain it. Changes to `LevelVar`s are goroutine-safe. +You might also consider adding a `ReplaceAttr` option to your handler, +like the [one for the built-in +handlers](https://pkg.go.dev/log/slog#HandlerOptions.ReplaceAttr). +Although `ReplaceAttr` will complicate your implementation, it will also +make your handler more generally useful. + The mutex will be used to ensure that writes to the `io.Writer` happen atomically. Unusually, `IndentHandler` holds a pointer to a `sync.Mutex` rather than holding a `sync.Mutex` directly. @@ -504,7 +510,9 @@ That is unlikely to matter in practice, but if it bothers you, you can use a linked list instead, which `Handle` will have to reverse or visit recursively. -See [github.com/jba/slog/withsupport](https://github.com/jba/slog/withsupport) for an implementation. +See the +[github.com/jba/slog/withsupport](https://github.com/jba/slog/tree/main/withsupport) +package for an implementation. #### Getting the mutex right
diff --git a/slog-handler-guide/guide.md b/slog-handler-guide/guide.md index 7aa4d7e..fb4664d 100644 --- a/slog-handler-guide/guide.md +++ b/slog-handler-guide/guide.md
@@ -109,6 +109,12 @@ will change the behavior of all handlers that contain it. Changes to `LevelVar`s are goroutine-safe. +You might also consider adding a `ReplaceAttr` option to your handler, +like the [one for the built-in +handlers](https://pkg.go.dev/log/slog#HandlerOptions.ReplaceAttr). +Although `ReplaceAttr` will complicate your implementation, it will also +make your handler more generally useful. + The mutex will be used to ensure that writes to the `io.Writer` happen atomically. Unusually, `IndentHandler` holds a pointer to a `sync.Mutex` rather than holding a `sync.Mutex` directly. @@ -323,7 +329,9 @@ That is unlikely to matter in practice, but if it bothers you, you can use a linked list instead, which `Handle` will have to reverse or visit recursively. -See [github.com/jba/slog/withsupport](https://github.com/jba/slog/withsupport) for an implementation. +See the +[github.com/jba/slog/withsupport](https://github.com/jba/slog/tree/main/withsupport) +package for an implementation. #### Getting the mutex right