From d102b825662a2e1f9ef084ad72f1a0ae608dd055 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Thu, 22 Nov 2018 16:31:01 -0500 Subject: [PATCH] Don't add more then one stderr handler --- piker/log.py | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/piker/log.py b/piker/log.py index b12aeae2..d3f6d769 100644 --- a/piker/log.py +++ b/piker/log.py @@ -72,21 +72,21 @@ def get_console_log(level: str = None, name: str = None) -> logging.Logger: if level: log.setLevel(level.upper() if not isinstance(level, int) else level) - if not any( - handler.stream == sys.stderr for handler in log.handlers - if getattr(handler, 'stream', None) - ): + for handler in log.handlers: + if getattr(handler, 'stream', None) and handler.stream == sys.stderr: + break + else: handler = logging.StreamHandler() - formatter = colorlog.ColoredFormatter( - LOG_FORMAT, - datefmt=DATE_FORMAT, - log_colors=STD_PALETTE, - secondary_log_colors=BOLD_PALETTE, - style='{', - ) - handler.setFormatter(formatter) - log.addHandler(handler) + formatter = colorlog.ColoredFormatter( + LOG_FORMAT, + datefmt=DATE_FORMAT, + log_colors=STD_PALETTE, + secondary_log_colors=BOLD_PALETTE, + style='{', + ) + handler.setFormatter(formatter) + log.addHandler(handler) return log