Skip to content

util/log: new JSON output formats#58126

Merged
craig[bot] merged 1 commit intocockroachdb:masterfrom
knz:20201221-fmt-json
Dec 31, 2020
Merged

util/log: new JSON output formats#58126
craig[bot] merged 1 commit intocockroachdb:masterfrom
knz:20201221-fmt-json

Conversation

@knz
Copy link
Copy Markdown
Contributor

@knz knz commented Dec 21, 2020

Fixes #44755

(This code was extracted from #57170 to further simplify it.)

Release note (cli change): It is now possible to set the format
parameter of any log sink, including file sinks, to json,
json-compact, json-fluent or json-fluent-compact to write
entries as structured JSON. Refer to the linked reference
documentation for details.

@knz knz requested a review from itsbilal December 21, 2020 14:52
@knz knz requested a review from a team as a code owner December 21, 2020 14:52
@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

@knz knz force-pushed the 20201221-fmt-json branch from 53dcf5e to e178bb5 Compare December 21, 2020 15:13
@knz knz force-pushed the 20201221-fmt-json branch from e178bb5 to 475f3d5 Compare December 21, 2020 15:56
@knz knz force-pushed the 20201221-fmt-json branch from 475f3d5 to b837842 Compare December 22, 2020 16:16
craig bot pushed a commit that referenced this pull request Dec 28, 2020
58031: util/log: delay the formatting of log entries r=itsbilal a=knz

Needed for #58126

Prior to this patch, the logging events were converted to a
`logpb.Entry` very early in the logging pipeline. This was forcing the
conversion of the logging tags to a flat string too early, and making
it hard for (e.g.) a JSON formatter to preserve the structure of
logging tags.

This patch averts this by introducing a new `logEntry` type which has
more-or-less the same structure as `logpb.Entry` but keep the logging
tags structured until the point the entry is formatted.

Release note: None

Co-authored-by: Raphael 'kena' Poss <knz@thaumogen.net>
@knz knz force-pushed the 20201221-fmt-json branch from b837842 to 11e6f0a Compare December 28, 2020 19:28
Copy link
Copy Markdown
Contributor

@itsbilal itsbilal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 7 of 7 files at r1, 6 of 6 files at r2.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained

Release note (cli change): It is now possible to set the `format`
parameter of any log sink, including file sinks, to `json`,
`json-compact`, `json-fluent` or `json-fluent-compact` to write
entries as structured JSON. Refer to the linked reference
documentation for details.
@knz knz force-pushed the 20201221-fmt-json branch from 11e6f0a to cebda3f Compare December 31, 2020 12:23
@knz
Copy link
Copy Markdown
Contributor Author

knz commented Dec 31, 2020

thanks!

bors r=itsbilal

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Dec 31, 2020

Build succeeded!

And happy new year! 🎉

@craig craig bot merged commit 567c426 into cockroachdb:master Dec 31, 2020
@knz knz deleted the 20201221-fmt-json branch December 31, 2020 13:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

log: implement flag that outputs all log messages as structured JSON

3 participants