Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Log] Support multiple CLI loggers #227

Merged
merged 2 commits into from
Dec 29, 2020
Merged

Conversation

jiasli
Copy link
Member

@jiasli jiasli commented Dec 28, 2020

Redo #221

  1. Revert cli_logger_name of knack.log.CLILogging.__init__ so that no breaking change is made.
  2. Support multiple cli loggers by adding more logger names to knack.log.cli_logger_names list.

Comment on lines +143 to 145
if root_logger.handlers:
# handlers already configured
return
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it enough when root_logger.handlers is set?
In previous code, both root_logger.handlers and cli_logger.handlers are checked.
Should we check all cli_logger.handlers for cli_logger in cli_loggers?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note really necessary, as root logger and cli logger are always set at the same time.

knack/knack/log.py

Lines 171 to 177 in 30592e0

root_logger.addHandler(_CustomStreamHandler(log_levels['root'],
log_formats['root'],
self.cli_ctx.enable_color))
cli_logger_console_handler = _CustomStreamHandler(log_levels['cli'], log_formats['cli'],
self.cli_ctx.enable_color)
for cli_logger in cli_loggers:
cli_logger.addHandler(cli_logger_console_handler)

@jiasli jiasli changed the title Support multiple CLI loggers [Log] Support multiple CLI loggers Dec 29, 2020
@jiasli jiasli merged commit 7aa098a into microsoft:master Dec 29, 2020
@jiasli jiasli deleted the multi-cli-logger branch December 29, 2020 02:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants