Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: divya-mohan0209 <divya.mohan0209@gmail.com>
  • Loading branch information
pohly and divya-mohan0209 committed May 2, 2022
1 parent b2e9304 commit ab353d9
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions content/en/blog/_posts/2022-05-25-contextual-logging/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ make log output more useful.

## Structured Logging

The goal for [structured
The goal of [structured
logging](https://github.com/kubernetes/enhancements/blob/master/keps/sig-instrumentation/1602-structured-logging/README.md)
is to replace C-style formatting and the resulting opaque log strings with log
entries that have a well-defined syntax for storing message and parameters
Expand All @@ -34,9 +34,8 @@ of text. internal:0}
I1112 14:06:35.783549 328441 structured_logging.go:52] "using InfoS with\nthe message across multiple lines" int=1 stringData="long: Multiple\nlines\nwith quite a bit\nof text." str="another value"
```

Now `<` and `>` markers and indention are used to ensure that splitting at a
klog header at the start of a line is reliable and the output remains readable
for humans:
Now, the `<` and `>` markers along with indentation are used to ensure that splitting at a
klog header at the start of a line is reliable and the resulting output is human-readable:

```
I1126 10:31:50.378204 121736 structured_logging.go:59] "using InfoS" longData=<
Expand Down Expand Up @@ -91,7 +90,7 @@ This enables additional use cases:
without interleaving their output.

One of the design decisions for contextual logging was to allow attaching a
logger as value to a `context.Context`. Because the logger encapsulates all
logger as value to a `context.Context`. Since the logger encapsulates all
aspects of the intended logging for the call, it is *part* of the context and
not just *using* it. A practical advantage is that many APIs already have a
`ctx` parameter or adding one has additional advantages, like being able to get
Expand All @@ -103,7 +102,7 @@ Another decision was to not break compatibility with klog v2:
set up contextual logging will work and log through the logging backend
chosen by the binary. However, such log output will not include the
additional information and will not work well in unit tests, so libraries
should get modified to support contextual logging. The [migration
should be modified to support contextual logging. The [migration
guide](https://github.com/kubernetes/community/blob/master/contributors/devel/sig-instrumentation/migration-to-structured-logging.md)
for structured logging has been extended to also cover contextual logging.

Expand Down

0 comments on commit ab353d9

Please sign in to comment.