From 997aadee31cfb770763d90d46d1c0d64037a9795 Mon Sep 17 00:00:00 2001 From: Travis Thieman Date: Mon, 15 Feb 2016 16:08:56 -0500 Subject: [PATCH] Always have handlers on client_logger to eliminate annoying warnings --- dusty/log.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/dusty/log.py b/dusty/log.py index 258a06d8..36ce1b3b 100644 --- a/dusty/log.py +++ b/dusty/log.py @@ -58,6 +58,7 @@ def close_socket_logger(): handler = None def configure_client_logging(): + client_logger.addHandler(logging.NullHandler()) logging.basicConfig(stream=sys.stdout, level=logging.INFO, format='%(message)s') @@ -71,14 +72,11 @@ def streaming_to_client(): was originally created for streaming Compose up's terminal output through to the client and should only be used for similarly complex circumstances.""" - handler = None - # Avoid annoying "No handlers could be found" warning - if client_logger.handlers: - for handler in client_logger.handlers: - if hasattr(handler, 'append_newlines'): - break - else: - handler = None + for handler in client_logger.handlers: + if hasattr(handler, 'append_newlines'): + break + else: + handler = None old_propagate = client_logger.propagate client_logger.propagate = False if handler is not None: