Skip to content

Commit 40afcb7

Browse files
committed
slog-handler-guide: fix typo, tweak phrasing
Fix one typo and improve the clarity and phrasing of some prose. Change-Id: I4cec5b052df0d33f6e4a3f2751313b3c1d59ae2c Reviewed-on: https://go-review.googlesource.com/c/example/+/636275 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Alan Donovan <adonovan@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
1 parent d7b0ac1 commit 40afcb7

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

slog-handler-guide/guide.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ The standard library’s `log/slog` package has a two-part design.
1515
A "frontend," implemented by the `Logger` type,
1616
gathers structured log information like a message, level, and attributes,
1717
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.
1919
But you may need to write your own handler, and that is not always straightforward.
2020
This guide is here to help.
2121

@@ -28,7 +28,7 @@ types work together.
2828
Each logger contains a handler. Certain `Logger` methods do some preliminary work,
2929
such 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

3333
An output method fulfills the main role of a logger: producing log output.
3434
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
314314
the same underlying array. If we used `append` instead of making an explicit
315315
copy, 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.
366366
This implementation is more complicated than the previous one.
367367
Is the extra complexity worth it?
368368
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
410410
with a simple counter, since an opened group's only effect is to change the
411411
indentation 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
414414
new 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
571571
server, logs provide the most detailed way to understand its behavior.
572572
Therefore, 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,
575575
like an invalid argument, is to panic or return an error.
576576
The built-in handlers do not follow that advice.
577577
Few things are more frustrating than being unable to debug a problem that

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy