From 01cc97424f099b03125e703dabcff4149460f667 Mon Sep 17 00:00:00 2001 From: Arun Babu Neelicattu Date: Tue, 26 Apr 2022 17:32:57 +0200 Subject: [PATCH] application: set global log handlers --- src/poetry/console/application.py | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/src/poetry/console/application.py b/src/poetry/console/application.py index 44a0efd7b0d..9f3ca17cedb 100644 --- a/src/poetry/console/application.py +++ b/src/poetry/console/application.py @@ -232,23 +232,30 @@ def register_command_loggers( handler = IOHandler(io) handler.setFormatter(IOFormatter()) + level = logging.WARNING + + if io.is_debug(): + level = logging.DEBUG + elif io.is_very_verbose() or io.is_verbose(): + level = logging.INFO + + logging.basicConfig(level=level, handlers=[handler]) + for name in loggers: logger = logging.getLogger(name) logger.handlers = [handler] - level = logging.WARNING + _level = level # The builders loggers are special and we can actually # start at the INFO level. - if logger.name.startswith("poetry.core.masonry.builders"): - level = logging.INFO - - if io.is_debug(): - level = logging.DEBUG - elif io.is_very_verbose() or io.is_verbose(): - level = logging.INFO + if ( + logger.name.startswith("poetry.core.masonry.builders") + and _level > logging.INFO + ): + _level = logging.INFO - logger.setLevel(level) + logger.setLevel(_level) def configure_env( self, event: ConsoleCommandEvent, event_name: str, _: Any