You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thanks for the comparison with different frameworks. That's very helpful.
I'd already thought about it and I'm all for it. Structured logging is the way to go.
My plan is to add a new entry to the log record, for example a data dict. This would be filled by the keyword arguments of the logged message instead of extra currently. This is because it should be viewed as semantically different.
Then, add {data} to the current default format, which would be nicely formatted (if non-empty), e.g.:
logger.info("Hello world", foo="bar", baz=123)
# => 2024-09-22 19:39:58.381 | INFO | __main__:<module>:1 - Hello world (foo="bar", baz=123)
Initially, I believed it should not, but maybe I'm wrong. I haven't given it enough thought. I need to look into the current usage made of contextualize() in relation to bind().
This is a suggestion to change default loguru text output format, or a new option to append extra to non-serialized text format.
There are many structured logging will include extra to text output, but loguru just ignore them.
Hope loguru could support this. For example, append
key1=value1 key2=value2
to default text output.so a code snippet will output
2024-09-12 00:17:01.261 | INFO | __main__:<module>:5 - hello world task=main pid=1
golang stdlib log/slog:
zerolog(golang)
pino(nodejs)
structlog(python)
The text was updated successfully, but these errors were encountered: