Merge pull request #1184 from jakedt/nullhandlers
Add a null handler to the root logger to silence test errors
This commit is contained in:
commit
a132d984e5
1 changed files with 6 additions and 1 deletions
7
app.py
7
app.py
|
@ -104,8 +104,13 @@ class InjectingFilter(logging.Filter):
|
|||
record.msg = '[%s] %s' % (request.request_id, record.msg)
|
||||
return True
|
||||
|
||||
root_logger = logging.getLogger()
|
||||
|
||||
# Add a null handler to the root logger to silence missing handler errors in tests
|
||||
root_logger.addHandler(logging.NullHandler())
|
||||
|
||||
# Add the request id filter to all handlers of the root logger
|
||||
for handler in logging.getLogger().handlers:
|
||||
for handler in root_logger.handlers:
|
||||
handler.addFilter(InjectingFilter())
|
||||
|
||||
app.request_class = RequestWithId
|
||||
|
|
Reference in a new issue