-
Notifications
You must be signed in to change notification settings - Fork 1
fix: honor configured framework runtime settings #368
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
Changes from all commits
7c9f50a
da0f891
0494f92
5709c6f
d77c378
29392f2
360a7da
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,6 +34,13 @@ | |
| logging.ERROR: "\033[0;31m", | ||
| logging.CRITICAL: "\033[0;31m", | ||
| } | ||
| _CONFIGURED_LOG_LEVELS = { | ||
| "debug": logging.DEBUG, | ||
| "info": logging.INFO, | ||
| "warning": logging.WARNING, | ||
| "error": logging.ERROR, | ||
| "critical": logging.CRITICAL, | ||
| } | ||
|
|
||
|
|
||
| # pylint: disable=too-many-arguments | ||
|
|
@@ -47,7 +54,23 @@ def configure_logger( | |
| formatter: logging.Formatter | None = None, | ||
| json_logs: bool = False, | ||
| run_id: str | None = None, | ||
| log_level: str | None = None, | ||
| ) -> logging.Logger: | ||
| """Configure user-facing and persistent handlers for a CLI logger. | ||
|
|
||
| ``log_level`` optionally selects the user-stream threshold from DEBUG, | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Doc/behavior mismatch: |
||
| INFO, WARNING, ERROR, or CRITICAL. The persistent file handler remains at | ||
| DEBUG. When omitted, the existing ``debug`` and ``quiet`` policy applies. | ||
| """ | ||
| normalized_log_level = log_level.lower() if log_level is not None else None | ||
| if normalized_log_level is not None and normalized_log_level not in _CONFIGURED_LOG_LEVELS: | ||
| supported = ", ".join(_CONFIGURED_LOG_LEVELS) | ||
| raise ValueError(f"log_level must be one of: {supported}.") | ||
| stream_level = ( | ||
| _user_stream_level(debug, quiet) | ||
| if normalized_log_level is None | ||
| else _CONFIGURED_LOG_LEVELS[normalized_log_level] | ||
| ) | ||
| logger = logging.getLogger(f"base_cli.{cli_name}") | ||
| logger.setLevel(logging.DEBUG) | ||
| logger.propagate = False | ||
|
|
@@ -57,7 +80,7 @@ def configure_logger( | |
|
|
||
| user_stream = stream if stream is not None else sys.stderr | ||
| user_handler = logging.StreamHandler(user_stream) | ||
| user_handler.setLevel(_user_stream_level(debug, quiet)) | ||
| user_handler.setLevel(stream_level) | ||
| user_handler.setFormatter( | ||
| _handler_formatter( | ||
| formatter, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reuse:
_parameter_source_was_suppliedhardcodes its own set of ClickParameterSourcenames instead of reusing_parameter_source_rankin_lifecycle_install.py, which this module already imports and which encodes the identical precedence ordering. If Click adds a newParameterSourcevariant, or_parameter_source_rank's ranking is edited, these two independently-maintained checks can silently diverge.