From 4082927c910496d75efb45d85b04ecd0c9cecd8b Mon Sep 17 00:00:00 2001 From: Drazzilb <65743746+Drazzilb08@users.noreply.github.com> Date: Thu, 15 Feb 2024 17:03:26 -0800 Subject: [PATCH] Fix multiple logging to docker --- util/logger.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/util/logger.py b/util/logger.py index 6517b73..10cb97c 100755 --- a/util/logger.py +++ b/util/logger.py @@ -73,7 +73,7 @@ def setup_logger(log_level, script_name, max_logs=9): # Add the file handler to the logger logger.addHandler(handler) - + # Configure console logging with the specified log level console_handler = logging.StreamHandler() if log_level == 'DEBUG': @@ -85,5 +85,10 @@ def setup_logger(log_level, script_name, max_logs=9): # Add the console handler to the logger logger.addHandler(console_handler) + + # Overwrite previous logger if exists + logging.getLogger(script_name).handlers.clear() + logging.getLogger(script_name).addHandler(handler) + logging.getLogger(script_name).addHandler(console_handler) return logger