From 135a742b6ed6065b00c95ab6e4cd65e3a3f9a334 Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Mon, 9 Jan 2023 11:25:58 +0100 Subject: [PATCH] config: add --console-stderr parameter --- mylib/config.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/mylib/config.py b/mylib/config.py index ea3952b..bacc4f7 100644 --- a/mylib/config.py +++ b/mylib/config.py @@ -817,6 +817,10 @@ class Config: # pylint: disable=too-many-instance-attributes BooleanOption, 'enabled', default=False, arg='--console', short_arg='-C', comment='Enable/disable console log') + section.add_option( + BooleanOption, 'force_stderr', default=False, + arg='--console-stderr', + comment='Force console log on stderr') section.add_option( StringOption, 'log_format', default=DEFAULT_CONSOLE_LOG_FORMAT, arg='--console-log-format', comment='Console log format') @@ -879,7 +883,9 @@ class Config: # pylint: disable=too-many-instance-attributes logging.getLogger().setLevel(logging.INFO) if self.get('console', 'enabled'): - stdout_console_handler = logging.StreamHandler(sys.stdout) + stdout_console_handler = logging.StreamHandler( + sys.stderr if self.get('console', 'force_stderr') + else sys.stdout) stdout_console_handler.addFilter(StdoutInfoFilter()) stdout_console_handler.setLevel(logging.DEBUG)