Skip to content

Commit 6c0e0b5

Browse files
committed
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.
1 parent c87fea7 commit 6c0e0b5

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

cms/log.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -391,16 +391,16 @@ def process(self, msg, kwargs):
391391

392392

393393
# Install a shell handler.
394-
shell_handler = StreamHandler(sys.stdout)
394+
shell_handler = StreamHandler(sys.stderr)
395395
shell_handler.setLevel(logging.INFO)
396-
shell_handler.setFormatter(CustomFormatter(has_color_support(sys.stdout)))
396+
shell_handler.setFormatter(CustomFormatter(has_color_support(sys.stderr)))
397397
root_logger.addHandler(shell_handler)
398398

399399

400400
def set_detailed_logs(detailed):
401401
"""Set or unset the shell logs to detailed."""
402402
global shell_handler
403-
color = has_color_support(sys.stdout)
403+
color = has_color_support(sys.stderr)
404404
formatter = DetailedFormatter(color) \
405405
if detailed else CustomFormatter(color)
406406
shell_handler.setFormatter(formatter)

cmsranking/Logger.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,9 +242,9 @@ def format(self, record):
242242
root_logger.setLevel(logging.DEBUG)
243243

244244
# Define the stream handler to output on stderr.
245-
shell_handler = StreamHandler(sys.stdout)
245+
shell_handler = StreamHandler(sys.stderr)
246246
shell_handler.setLevel(logging.INFO)
247-
shell_handler.setFormatter(CustomFormatter(has_color_support(sys.stdout)))
247+
shell_handler.setFormatter(CustomFormatter(has_color_support(sys.stderr)))
248248
root_logger.addHandler(shell_handler)
249249

250250

0 commit comments

Comments
 (0)