From 8c82fb44ae92c5acb306aaf85f865f868ca18b98 Mon Sep 17 00:00:00 2001 From: Jake Moshenko Date: Thu, 28 Jan 2016 11:30:47 -0500 Subject: [PATCH] Add a null handler to the root logger to silence test errors --- app.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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