LukeMathWalker / zero-to-production

Code for "Zero To Production In Rust", a book on API development using Rust.
https://www.zero2prod.com
Apache License 2.0
5.86k stars 519 forks source link

Could we improve logs? #239

Closed psprojectC closed 11 months ago

psprojectC commented 11 months ago

While I was following the book the biggest problem for me was how unreadable the logs appeared to be. Main problem is they're all on one line and there is no indentation so it's really hard to figure out what's going on at a glance. I ended up doing fuckery of my own which resulted in something looking like this: image It's not perfect by any means, but it has colors and some newlines at least. Can tracing-bunyan (or whatever you're using - I forgot what it was) be extended to support pretty printing a log event and optionally add colors?

LukeMathWalker commented 11 months ago

tracing-bunyan-formatter is optimised for production usage—you won't be eyeballing logs in a terminal; they'll be shipped to a system that gives you a query interface and a nice UI to sift through them (e.g. Elastic, Honeycomb, etc.).

You can use a different tracing subscriber for local development, but that's outside what tracing-bunyan-formatter cares about.