File tree 2 files changed +18
-2
lines changed
2 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -147,6 +147,12 @@ If the user instead passes a `LevelVar`, then a single change to that `LevelVar`
147
147
will change the behavior of all handlers that contain it.
148
148
Changes to ` LevelVar ` s are goroutine-safe.
149
149
150
+ You might also consider adding a ` ReplaceAttr ` option to your handler,
151
+ like the [ one for the built-in
152
+ handlers] ( https://pkg.go.dev/log/slog#HandlerOptions.ReplaceAttr ) .
153
+ Although ` ReplaceAttr ` will complicate your implementation, it will also
154
+ make your handler more generally useful.
155
+
150
156
The mutex will be used to ensure that writes to the ` io.Writer ` happen atomically.
151
157
Unusually, ` IndentHandler ` holds a pointer to a ` sync.Mutex ` rather than holding a
152
158
` sync.Mutex ` directly.
@@ -504,7 +510,9 @@ number of calls to those methods, because of the repeated copying.
504
510
That is unlikely to matter in practice, but if it bothers you,
505
511
you can use a linked list instead,
506
512
which ` Handle ` will have to reverse or visit recursively.
507
- See [ github.com/jba/slog/withsupport] ( https://github.com/jba/slog/withsupport ) for an implementation.
513
+ See the
514
+ [ github.com/jba/slog/withsupport] ( https://github.com/jba/slog/tree/main/withsupport )
515
+ package for an implementation.
508
516
509
517
#### Getting the mutex right
510
518
Original file line number Diff line number Diff line change @@ -109,6 +109,12 @@ If the user instead passes a `LevelVar`, then a single change to that `LevelVar`
109
109
will change the behavior of all handlers that contain it.
110
110
Changes to ` LevelVar ` s are goroutine-safe.
111
111
112
+ You might also consider adding a ` ReplaceAttr ` option to your handler,
113
+ like the [ one for the built-in
114
+ handlers] ( https://pkg.go.dev/log/slog#HandlerOptions.ReplaceAttr ) .
115
+ Although ` ReplaceAttr ` will complicate your implementation, it will also
116
+ make your handler more generally useful.
117
+
112
118
The mutex will be used to ensure that writes to the ` io.Writer ` happen atomically.
113
119
Unusually, ` IndentHandler ` holds a pointer to a ` sync.Mutex ` rather than holding a
114
120
` sync.Mutex ` directly.
@@ -323,7 +329,9 @@ number of calls to those methods, because of the repeated copying.
323
329
That is unlikely to matter in practice, but if it bothers you,
324
330
you can use a linked list instead,
325
331
which ` Handle ` will have to reverse or visit recursively.
326
- See [ github.com/jba/slog/withsupport] ( https://github.com/jba/slog/withsupport ) for an implementation.
332
+ See the
333
+ [ github.com/jba/slog/withsupport] ( https://github.com/jba/slog/tree/main/withsupport )
334
+ package for an implementation.
327
335
328
336
#### Getting the mutex right
329
337
You can’t perform that action at this time.
0 commit comments