Merge pull request #1184 from jakedt/nullhandlers

Add a null handler to the root logger to silence test errors
This commit is contained in:
Jake Moshenko 2016-01-28 13:27:23 -05:00
commit a132d984e5

7
app.py
View file

@ -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