Ugly hack to have the name of the main logger, otherwise error/exception messages ain't displayed

This commit is contained in:
Alexandre Aubin 2020-08-27 19:21:48 +02:00
parent 9609fe1210
commit 2501ecda56
2 changed files with 4 additions and 4 deletions

View file

@ -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

View file

@ -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)