diff --git a/app.py b/app.py index 79635fbd6..aeef0ef55 100644 --- a/app.py +++ b/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