Conversation
There was a problem hiding this comment.
🟡 Changes recommended
The current approach passes a partial handler dict via config, which can break handler initialization (and potentially crash import-time auto-loading) when colorization is disabled.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR updates beans_logging.auto to make LoggerLoader initialization sensitive to the BEANS_LOGGING_AUTO_COLORIZED environment variable, so colorized log output can be disabled dynamically at import time.
Changes:
- Read
BEANS_LOGGING_AUTO_COLORIZEDfrom the environment and interpret it as a boolean. - When disabled, attempt to adjust the default STD handler configuration to set
colorize=False. - Refactor
LoggerLoaderinstantiation to use a kwargs dict and**_kwargs.
File summaries
| File | Description |
|---|---|
| src/beans_logging/auto.py | Adds env-driven colorization toggle and refactors LoggerLoader construction accordingly. |
Review details
- Files reviewed: 1/1 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+15
to
+17
| _kwargs: dict[str, Any] = {"auto_load": True} | ||
| if not _is_colorized: | ||
| _kwargs["config"] = {"handlers": {DEFAULT_STD_HANDLER_NAME: {"colorize": False}}} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request updates the initialization logic for
LoggerLoaderinsrc/beans_logging/auto.pyto allow dynamic control over log colorization based on theBEANS_LOGGING_AUTO_COLORIZEDenvironment variable. The code now conditionally disables colorized output if the environment variable is set to a falsy value.The most important changes include:
Environment-based configuration:
BEANS_LOGGING_AUTO_COLORIZEDenvironment variable and determine whether log colorization should be enabled or disabled.colorize: Falsefor the default handler (DEFAULT_STD_HANDLER_NAME).Code refactoring:
LoggerLoaderto use keyword arguments based on the environment-driven configuration.