@@ -15,7 +15,7 @@ The standard library’s `log/slog` package has a two-part design.
1515A "frontend," implemented by the ` Logger ` type,
1616gathers structured log information like a message, level, and attributes,
1717and 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.
1919But you may need to write your own handler, and that is not always straightforward.
2020This guide is here to help.
2121
@@ -28,7 +28,7 @@ types work together.
2828Each logger contains a handler. Certain ` Logger ` methods do some preliminary work,
2929such as gathering key-value pairs into ` Attr ` s, and then call one or more
3030` Handler ` methods. These ` Logger ` methods are ` With ` , ` WithGroup ` ,
31- and the output methods.
31+ and the output methods like ` Info ` , ` Error ` and so on .
3232
3333An output method fulfills the main role of a logger: producing log output.
3434Here 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
314314the same underlying array. If we used ` append ` instead of making an explicit
315315copy, we would introduce that subtle aliasing bug.
316316
317- Using ` withGroupOrAttrs ` , the ` With ` methods are easy:
317+ The ` With ` methods are easy to write using ` withGroupOrAttrs ` :
318318
319319%include indenthandler2/indent_handler.go withs -
320320
@@ -362,7 +362,7 @@ See [this bug report](https://go.dev/issue/61321) for more detail.
362362
363363### With pre-formatting
364364
365- Our second implementation implements pre-formatting.
365+ Our second version of the ` WithGroup ` and ` WithAttrs ` methods provides pre-formatting.
366366This implementation is more complicated than the previous one.
367367Is the extra complexity worth it?
368368That 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
410410with a simple counter, since an opened group's only effect is to change the
411411indentation level.
412412
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
414414new group, which is unopened initially.
415415
416416%include indenthandler3/indent_handler.go WithGroup -
@@ -571,7 +571,7 @@ impossible to inspect a system, as is typically the case with a production
571571server, logs provide the most detailed way to understand its behavior.
572572Therefore, your handler should be robust to bad input.
573573
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,
575575like an invalid argument, is to panic or return an error.
576576The built-in handlers do not follow that advice.
577577Few things are more frustrating than being unable to debug a problem that
0 commit comments