Content-Length: 288987 | pFad | https://github.com/rs/zerolog/pull/449

A4 CLI utility to pipe JSON logs through to pretty print and colorize them by themarolt · Pull Request #449 · rs/zerolog · GitHub
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLI utility to pipe JSON logs through to pretty print and colorize them #449

Merged
merged 5 commits into from
Sep 3, 2022

Conversation

themarolt
Copy link
Contributor

Implemented a small utility tool to use when developing an application using zerolog as mentioned in #316.

The only thing that is untested is Windows instructions specifically commands that redirect stderr to stdout:

some_program_with_zerolog 2>&1 | go run cmd/pretty_pipe/pretty_pipe.go

Can someone verify this is working? I only have access to a Linux machine currently.

cmd/pretty_pipe/README.md Outdated Show resolved Hide resolved
cmd/pretty_pipe/pretty_pipe.go Outdated Show resolved Hide resolved
Humans are visual beings so the preferred format should be ordinary `Console` format with colors if possible.

Zerolog ships with `ConsoleWriter` which does exactly that. But modifying your code to get pretty printed and colorized
logs is somewhat difficult.
Copy link
Owner

Choose a reason for hiding this comment

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

A simpler solution to the problem described here is to detect if the stdout is a terminal and automatically enable console mode if it is. This is a trick I may add as conditional writer in the lib.

I still think this tool is useful when you need to tail zerolog produced output in prod for instance, or in settings when you need both JSON and pretty output.

Could you change the text of the readme to remove the part about why you need this tool so it does not come as the recommended solution to solve this problem?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes - of course. I updated the README.md - now it's just a description and usage.

Sorry for taking so long - was on vacation during the summer :)

@rs rs merged commit c2b9d0e into rs:master Sep 3, 2022
pablitoc pushed a commit to nxcr-org/zerolog that referenced this pull request Apr 7, 2023
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.

3 participants








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://github.com/rs/zerolog/pull/449

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy