-
-
Notifications
You must be signed in to change notification settings - Fork 222
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 ExtraAdder
Processor function to structlog.stdlib
#377
Conversation
40e5458
to
70d346a
Compare
Since you refer to 209 and also note yourself in #378 that adding all of callsite info would be overwhelming, I'd like to refer to my comment. I think adding all data ist just too much. We just have to decide if we want to take an allowlist or an disallowlist approach. Since you've taken an allowlist approach in #380, I would say the same would be good here too? I usually like it better since it gives one more control. We can't use enums of course, because we don't know what keys that user has added. |
Okay sounds like a good idea, I will change this to a processor class and add an allow list, and also provide an option for allowing copying of all values. |
Yes, that's even better! |
maybe just make it i.e. |
This will be simplest, I will go for this, will update PR tonight (CET) |
This processor function will add extra attributres from LogRecord objects to the event_dict, and can be useful for making values passed in the extra parameter of the logging module's log methods pass through to output as additional properties. Fixes hynek#209
- fix assert parameter order - add `add_extra` to `__all__`
This is so ExtraAdder can be configured with what keys it should copy.
70d346a
to
95857ae
Compare
Okay I converted it to a processor class, |
- Fix up documentation - Improve tests
7eb8ec8
to
100b43d
Compare
add_extra
Processor functionExtraAdder
Processor function to structlog.stdlib
Documentation and changelog updated now also. I made the allow parameter a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've found a few nits, but they don't warrant another review round. This is great – thank you!
(I've merged it in 9208a2c because I couldn't push into your branch – thanks again!) |
@hynek I will add tests for the two uncovered lines tonight (again CET), did not realize that test coverage target is 100% but should have added a test for case where there is no log record. I will also add a comment for And please mention other issues if there are, will update them as I get time. I will also make a PR to update PULL_REQUEST_TEMPLATE with:
|
I've fixed the coverage; feel free to open a hock PR for the allow thing tho! |
(i've also updated the template – sorry i've misread your comment on the go on a phone. i've only noticed you want to do it after looking up the PR id to refer to it) |
Summary
Added the
structlog.stdlib.ExtraAdder
processor that adds extra attributes oflogging.LogRecord
objects to the event dictionary.This processor can be used for adding data passed in the
extra
parameter of thelogging
module's log methods to the event dictionary.Fixes #209
Pull Request Check List
This is just a friendly reminder about the most common mistakes. Please make sure that you tick all boxes. But please read our contribution guide at least once, it will save you unnecessary review cycles!
If an item doesn't apply to your pull request, check it anyway to make it apparent that there's nothing left to do.
typing_examples.py
.docs/api.rst
by hand.versionadded
,versionchanged
, ordeprecated
directives. Find the appropriate next version in our__init__.py
file..rst
files is written using semantic newlines.If you have any questions to any of the points above, just submit and ask! This checklist is here to help you, not to deter you from contributing!