Skip to content
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

log extra param does not work with picologging #195

Open
GabrielCappelli opened this issue Nov 4, 2023 · 1 comment
Open

log extra param does not work with picologging #195

GabrielCappelli opened this issue Nov 4, 2023 · 1 comment

Comments

@GabrielCappelli
Copy link
Contributor

Passing the extra param on log calls behaves different in picologging compared to stdlib.

Sample code:

import logging
# import picologging as logging

logging.basicConfig(format="message=%(message)s foo=%(foo)s", level=logging.DEBUG)
logging.debug("msg", extra={"foo": "bar"})

Output with std logging: message=msg foo=bar
Output with picologging: AttributeError: 'picologging.LogRecord' object has no attribute 'foo'

@GabrielCappelli
Copy link
Contributor Author

stdlib logging will update LogRecord.__dict__ directly to add the extra items to the log record object.
https://github.com/python/cpython/blob/main/Lib/logging/__init__.py#L1620-L1624

But, just in case you plan to change this behaviour :)... For my personal use case (JSON structured logging), it would be best if extra was simply a field in LogRecord that I could access in a custom Formatter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant