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

Allow foreign_pre_chain To Read Foreign Log Args #228

Merged

Conversation

jonathanmeier5
Copy link
Contributor

@jonathanmeier5 jonathanmeier5 commented Sep 26, 2019

Resolves #227

When migrating a project from stdlib logging to structlog, an easy first step is to use ProcessorFormatter with processors defined in foreign_pre_chain. These will run on every stdlib log message sent into the formatter.

However, right now there is no way to access a LogRecord's args in the foreign_pre_chain processors because they are stripped before the record is passed to the processors.

This PR introduces a pass_foreign_args kwarg to ProcessorFormatter. When set to True, it will inject a foreign log record's args attribute into the event_dict under the positional_args key before stripping them from the record.

@hynek hynek merged commit 5a3599e into hynek:master Oct 15, 2019
22 checks passed
@hynek
Copy link
Owner

@hynek hynek commented Oct 15, 2019

Thanks! There's a bunch of very minor things but now that 3.8 has been dropped on me I need to publish fast so I'll shape it up myself.

hynek added a commit that referenced this issue Oct 15, 2019
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

Successfully merging this pull request may close these issues.

2 participants