From 2501ecda56bd6dcdde2fc863be5352d66d00b225 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Thu, 27 Aug 2020 19:21:48 +0200 Subject: [PATCH] Ugly hack to have the name of the main logger, otherwise error/exception messages ain't displayed --- moulinette/__init__.py | 7 +++---- moulinette/utils/log.py | 1 + 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/moulinette/__init__.py b/moulinette/__init__.py index 9ed0220c..1bb9b818 100755 --- a/moulinette/__init__.py +++ b/moulinette/__init__.py @@ -90,12 +90,12 @@ def api(host="localhost", port=80, routes={}): except MoulinetteError as e: import logging - logging.getLogger().error(e.strerror) + logging.getLogger(logging.main_logger).error(e.strerror) return 1 except KeyboardInterrupt: import logging - logging.getLogger().info(m18n.g("operation_interrupted")) + logging.getLogger(logging.main_logger).info(m18n.g("operation_interrupted")) return 0 @@ -121,8 +121,7 @@ def cli(args, top_parser, output_as=None, timeout=None): ) except MoulinetteError as e: import logging - - logging.getLogger().error(e.strerror) + logging.getLogger(logging.main_logger).error(e.strerror) return 1 return 0 diff --git a/moulinette/utils/log.py b/moulinette/utils/log.py index 16a3fc23..e1a902b5 100644 --- a/moulinette/utils/log.py +++ b/moulinette/utils/log.py @@ -65,6 +65,7 @@ def configure_logging(logging_config=None): # load configuration from dict dictConfig(DEFAULT_LOGGING) if logging_config: + logging.main_logger = logging_config.get("main_logger") dictConfig(logging_config)