BrunoBonacci / mulog

μ/log is a micro-logging library that logs events and data, not words!
https://cljdoc.org/d/com.brunobonacci/mulog/
Apache License 2.0
485 stars 47 forks source link

Indentation-aligned log lines #62

Open nivekuil opened 3 years ago

nivekuil commented 3 years ago

I inadvertently discovered that mulog's structured logging facilitates map alignment to make the log events, in my eyes, a lot more readable:

{:mulog/event-name :app.server/api,
 :mulog/timestamp "Tue Apr 06 14:18:11 PDT 2021",
 :mulog/duration 0.741753,
 :mulog/namespace "app.server",
 :mulog/outcome :ok,
 :req/user #uuid "0dc03bed-b65d-4bef-89f3-37635ea8ff8f"}

{:mulog/event-name :app.server/api,
 :mulog/timestamp  "Tue Apr 06 14:18:20 PDT 2021",
 :mulog/duration   0.630531,
 :mulog/namespace  "app.server",
 :mulog/outcome    :ok,
 :req/user         #uuid "0dc03bed-b65d-4bef-89f3-37635ea8ff8f"}

Currently this is done with aggressive-indent-mode on in the repl buffer. Maybe it makes sense to add to mulog directly, fitting in with pretty logging as part of https://github.com/BrunoBonacci/mulog/pull/45?

BrunoBonacci commented 3 years ago

Interesting, the default pretty-printing doesn't align the values, but with the Ansi logger we could look into this.