-
Notifications
You must be signed in to change notification settings - Fork 711
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
add extra to default text output format #1200
Comments
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 Then, add 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) |
will kwargs from |
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 |
that should be really useful. but for example :
should "a=1" included? and I also read loguru source code, it can not clearly distinguish between 'bind' and 'format-placeholder', maybe we should add some new func with propagation to handler this. boring but works like this
|
I think it should |
@elvizlai Regarding the following example: logger.bind(a=1).info("good {}, nice {b}", "morning", b="job", c="come on") I think that the next version of Loguru must clearly distinguish between :
Currently there is some undesirable overlap: keyword arguments end up both in the I was planning to do is the following:
In such scenario, that means the This is because, I believe keyword arguments to be contextual to the log line, and I don't want this to inadvertently override a value configured by from loguru import logger
# Imagine a filter or sink implements a specialization for this named logger.
named_logger = logger.bind(name="my-specific-logger")
named_logger.info("App initialized", count=123)
named_logger.info("New user connected", name=username) # Oops! I believe there should be a conceptual difference between |
missing |
Yes, I'm not sure yet if it falls more into the category of |
I vote for |
Yes, it's also what seems most natural to me. |
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: