From e8919e54ece04e8b6007a74dd713e48517c4a925 Mon Sep 17 00:00:00 2001 From: Matt Sayler Date: Mon, 5 Oct 2020 08:50:45 -0500 Subject: [PATCH] Don't duplicate logger hander (#86) --- almdrlib/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/almdrlib/__init__.py b/almdrlib/__init__.py index 9728128..fd6dc44 100644 --- a/almdrlib/__init__.py +++ b/almdrlib/__init__.py @@ -36,7 +36,10 @@ def set_logger(name='almdrlib', level=logging.DEBUG, format_string=None): handler.setLevel(level) formatter = logging.Formatter(format_string) handler.setFormatter(formatter) - logger.addHandler(handler) + + # avoid duplicate logs if already set by caller, etc. + if not logger.handlers: + logger.addHandler(handler) def _get_default_session():