Skip to content

Commit

Permalink
[Log] CLILogging.configure returns as early as possible (#228)
Browse files Browse the repository at this point in the history
  • Loading branch information
jiasli committed Jan 25, 2021
1 parent 7aa098a commit c6f2aed
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions knack/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,16 @@ def configure(self, args):
:param args: The arguments from the command line
:type args: list
"""
root_logger = logging.getLogger()

if root_logger.handlers:
# handlers already configured
return

self.log_level = self._determine_log_level(args)
console_log_levels = self._get_console_log_levels()
console_log_formats = self._get_console_log_formats()

root_logger = logging.getLogger()
# Set the levels of the loggers to lowest level.
# Handlers can override by choosing a higher level.
root_logger.setLevel(logging.DEBUG)
Expand All @@ -140,9 +145,6 @@ def configure(self, args):
cli_logger.setLevel(logging.DEBUG)
cli_logger.propagate = False

if root_logger.handlers:
# handlers already configured
return
self._init_console_handlers(root_logger, cli_loggers, console_log_levels, console_log_formats)
if self.file_log_enabled:
self._init_logfile_handlers(root_logger, cli_loggers)
Expand Down

0 comments on commit c6f2aed

Please sign in to comment.