Misc logging fixes

This commit is contained in:
Alexandre Aubin 2021-01-31 16:08:50 +01:00
parent e7a01c68f5
commit bdd048197d
4 changed files with 6 additions and 7 deletions

View file

@ -90,12 +90,12 @@ def api(host="localhost", port=80, routes={}):
except MoulinetteError as e:
import logging
logging.getLogger(logging.main_logger).error(e.strerror)
logging.getLogger("moulinette").error(e.strerror)
return 1
except KeyboardInterrupt:
import logging
logging.getLogger(logging.main_logger).info(m18n.g("operation_interrupted"))
logging.getLogger("moulinette").info(m18n.g("operation_interrupted"))
return 0
@ -122,7 +122,7 @@ def cli(args, top_parser, output_as=None, timeout=None):
except MoulinetteError as e:
import logging
logging.getLogger(logging.main_logger).error(e.strerror)
logging.getLogger("moulinette").error(e.strerror)
return 1
return 0

View file

@ -577,14 +577,14 @@ class ActionsMap(object):
log_id = start_action_logging()
if logger.isEnabledFor(logging.DEBUG):
# Log arguments in debug mode only for safety reasons
logger.info(
logger.debug(
"processing action [%s]: %s with args=%s",
log_id,
full_action_name,
arguments,
)
else:
logger.info("processing action [%s]: %s", log_id, full_action_name)
logger.debug("processing action [%s]: %s", log_id, full_action_name)
# Load translation and process the action
m18n.load_namespace(namespace)

View file

@ -208,7 +208,7 @@ class _HTTPArgumentParser(object):
def _error(self, message):
# TODO: Raise a proper exception
raise MoulinetteError(message)
raise MoulinetteError(message, raw_msg=True)
class _ActionsMapPlugin(object):

View file

@ -65,7 +65,6 @@ 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)