From 39574c8078ced3fd0eaa5af07a6aab70f2a126ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Mare=C5=A1?= Date: Sat, 22 Jun 2024 22:11:38 +0200 Subject: [PATCH] Logs should go to stderr Currently, we log to stdout, which is contrary to UNIX conventions. Also, it makes it impossible to redirect normal standard output of commands like cmsRWSHelper to a file. Closes #1382. --- cms/log.py | 6 +++--- cmsranking/Logger.py | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cms/log.py b/cms/log.py index b8c47b64ef..367ad1ebbc 100644 --- a/cms/log.py +++ b/cms/log.py @@ -393,16 +393,16 @@ def process(self, msg: str, kwargs: dict): # Install a shell handler. -shell_handler = StreamHandler(sys.stdout) +shell_handler = StreamHandler(sys.stderr) shell_handler.setLevel(logging.INFO) -shell_handler.setFormatter(CustomFormatter(has_color_support(sys.stdout))) +shell_handler.setFormatter(CustomFormatter(has_color_support(sys.stderr))) root_logger.addHandler(shell_handler) def set_detailed_logs(detailed: bool): """Set or unset the shell logs to detailed.""" global shell_handler - color = has_color_support(sys.stdout) + color = has_color_support(sys.stderr) formatter = DetailedFormatter(color) \ if detailed else CustomFormatter(color) shell_handler.setFormatter(formatter) diff --git a/cmsranking/Logger.py b/cmsranking/Logger.py index c5889d34e4..5675cc46fc 100644 --- a/cmsranking/Logger.py +++ b/cmsranking/Logger.py @@ -243,9 +243,9 @@ def format(self, record): root_logger.setLevel(logging.DEBUG) # Define the stream handler to output on stderr. -shell_handler = StreamHandler(sys.stdout) +shell_handler = StreamHandler(sys.stderr) shell_handler.setLevel(logging.INFO) -shell_handler.setFormatter(CustomFormatter(has_color_support(sys.stdout))) +shell_handler.setFormatter(CustomFormatter(has_color_support(sys.stderr))) root_logger.addHandler(shell_handler)