Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a fix to the issue that occurs when running a script with this module imported:
Before:
If you imported this module, it would change the root logger, and how it formatted logs, including a
context
element in the message. Since the module wants to send a log file to a specific file it created two handlers, one for the console and one for the log file, with differing levels (amongst other changes). The context filter (which creates default context for any logger message that doesnt have one from root upwards) wasn't added two both handlers and just added to the logger (usinglogger.addFilter()
). This lead to hundreds of logging errors where the console handler couldn't findcontext
. This made the logs literally impossible to read in terminal and made development very difficult.After:
I have looped through all handlers and have added the filter specifically to each handler. This was a fix I had to implement in the
airflow-matrix-scraper
repo by editing the root handler and doing the exact same thing, so hoping fix will carry over to here.