rs / zerolog

Zero Allocation JSON Logger
MIT License
10.39k stars 566 forks source link

Add a binary to format JSON logs as string #612

Closed freak12techno closed 8 months ago

freak12techno commented 10 months ago

It would be nice if there would be a binary that one can pipe JSON logs to and would get a prettified colored output that is human-readable.

My use case: at one or my previous jobs, we had all the apps logging as JSON objects, as we were using Elastic stack and it's way more convenient to use JSON for processing, but sometimes there was a need to SSH into a specific server and see logs on it directly, and JSON is not very human readable, so we had something like this (we weren't using zero log, we used Node.js and Bunyan, but the idea is the same):

tail -f log.txt | bunyan

And this bunyan tool prettified all JSON logs that were piped into it and displayed a pretty-formatted human-readable logs strings. Which is extra useful especially if it comes to debugging.

So I was wondering if that's achievable, what do you think?

tulir commented 10 months ago

Do you mean something like https://github.com/rs/zerolog/tree/master/cmd/prettylog?

freak12techno commented 10 months ago

@tulir actually I wasn't aware of that, seems like it perfectly suits my needs. Can one install it via go install?

freak12techno commented 8 months ago

Yes, one can. Closing as resolved.