@@ -15,7 +15,7 @@ The standard library’s `log/slog` package has a two-part design.
15
15
A "frontend," implemented by the ` Logger ` type,
16
16
gathers structured log information like a message, level, and attributes,
17
17
and passes them to a "backend," an implementation of the ` Handler ` interface.
18
- The package comes with two built-in handlers that usually should be adequate.
18
+ The package comes with two built-in handlers that should usually be adequate.
19
19
But you may need to write your own handler, and that is not always straightforward.
20
20
This guide is here to help.
21
21
@@ -28,7 +28,7 @@ types work together.
28
28
Each logger contains a handler. Certain ` Logger ` methods do some preliminary work,
29
29
such as gathering key-value pairs into ` Attr ` s, and then call one or more
30
30
` Handler ` methods. These ` Logger ` methods are ` With ` , ` WithGroup ` ,
31
- and the output methods.
31
+ and the output methods like ` Info ` , ` Error ` and so on .
32
32
33
33
An output method fulfills the main role of a logger: producing log output.
34
34
Here is a call to an output method:
@@ -314,7 +314,7 @@ Most of the fields of `IndentHandler` can be copied shallowly, but the slice of
314
314
the same underlying array. If we used ` append ` instead of making an explicit
315
315
copy, we would introduce that subtle aliasing bug.
316
316
317
- Using ` withGroupOrAttrs ` , the ` With ` methods are easy:
317
+ The ` With ` methods are easy to write using ` withGroupOrAttrs ` :
318
318
319
319
%include indenthandler2/indent_handler.go withs -
320
320
@@ -362,7 +362,7 @@ See [this bug report](https://go.dev/issue/61321) for more detail.
362
362
363
363
### With pre-formatting
364
364
365
- Our second implementation implements pre-formatting.
365
+ Our second version of the ` WithGroup ` and ` WithAttrs ` methods provides pre-formatting.
366
366
This implementation is more complicated than the previous one.
367
367
Is the extra complexity worth it?
368
368
That depends on your circumstances, but here is one circumstance where
@@ -410,7 +410,7 @@ We also need to track how many groups we've opened, which we can do
410
410
with a simple counter, since an opened group's only effect is to change the
411
411
indentation level.
412
412
413
- The ` WithGroup ` implementation is a lot like the previous one: just remember the
413
+ This ` WithGroup ` is a lot like the previous one: it just remembers the
414
414
new group, which is unopened initially.
415
415
416
416
%include indenthandler3/indent_handler.go WithGroup -
@@ -571,7 +571,7 @@ impossible to inspect a system, as is typically the case with a production
571
571
server, logs provide the most detailed way to understand its behavior.
572
572
Therefore, your handler should be robust to bad input.
573
573
574
- For example, the usual advice when when a function discovers a problem,
574
+ For example, the usual advice when a function discovers a problem,
575
575
like an invalid argument, is to panic or return an error.
576
576
The built-in handlers do not follow that advice.
577
577
Few things are more frustrating than being unable to debug a problem that
0 commit comments