Conversation
… auto.py to streamline log level handling
There was a problem hiding this comment.
🔵 Needs a closer look
Environment overrides for format, colorization, and precedence must be corrected before approval.
Pull request overview
Adds environment-variable controls for automatic logging level, colorization, and format, with documentation updates.
Changes:
- Adds logging environment-variable handling in
auto.py. - Documents the settings in
README.mdand.env.example.
File summaries
| File | Summary |
|---|---|
src/beans_logging/auto.py |
Applies environment-based handler settings; format and colorization overrides are not reliably applied. |
README.md |
Documents logging environment variables, including the currently ineffective format override. |
.env.example |
Adds logging configuration examples, including the currently ineffective format override. |
Review details
Suppressed comments (4)
.env.example:7
- This new example advertises a format override that is currently ignored.
auto.pyputs the value underformat_in the serialized handlers config, whileLoggerConfigPMserializes the default asformatandLogHandlerPMgives that validation alias precedence when both keys are present. Please fix the implementation to pass the alias (format) or apply the override after model validation before documenting this variable.
# BEANS_LOGGING_AUTO_FORMAT="[<c>{time:YYYY-MM-DD HH:mm:ss.SSS Z}</c> | <level>{extra[level_short]:<5}</level> | <w>{name}:{line}</w>]: <level>{message}</level>"
README.md:288
- This new example advertises a format override that is currently ignored.
auto.pyputs the value underformat_in the serialized handlers config, whileLoggerConfigPMserializes the default asformatandLogHandlerPMgives that validation alias precedence when both keys are present. Please fix the implementation to pass the alias (format) or apply the override after model validation before documenting this variable.
# BEANS_LOGGING_AUTO_FORMAT="[<c>{time:YYYY-MM-DD HH:mm:ss.SSS Z}</c> | <level>{extra[level_short]:<5}</level> | <w>{name}:{line}</w>]: <level>{message}</level>"
src/beans_logging/auto.py:21
- This branch only adds
colorizewhen the parsed value is false, soBEANS_LOGGING_AUTO_COLORIZED=trueproduces no override. If the existingstd_handlerconfiguration hascolorize: false, the documented true setting cannot enable colorization; emit the key whenever the environment variable is present and use the parsed boolean for either value.
if not _is_colorized:
_handler_config["colorize"] = False
src/beans_logging/auto.py:27
- These handler overrides are installed before
LoggerLoader(auto_load=True)callsload(load_config_file=True)._load_config_file()then mergesconfigs/logger.ymlon top of the current config, so the documented/templateformatandcolorizevalues (and any configured handlerlevel) win over these environment variables. As a result, the environment settings do not reliably configure auto logging when a config file is present; apply the environment override after file loading or otherwise define the intended precedence.
if _level:
_handler_config["level"] = _level
- Files reviewed: 3/3 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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 introduces support for configuring the logging behavior of the
beans_logging.automodule via environment variables. The changes make it easier to control log level, colorization, and format settings without modifying code, and provide clear documentation and examples for users.Environment variable-based logging configuration:
BEANS_LOGGING_AUTO_LEVEL), colorization (BEANS_LOGGING_AUTO_COLORIZED), and log format (BEANS_LOGGING_AUTO_FORMAT) through environment variables inbeans_logging/auto.py. These are now read at runtime and applied to the logging handler configuration. [1] [2]Documentation updates:
.env.exampleand the logger section ofREADME.mdto include commented examples of the new logging-related environment variables, helping users understand available options and their usage. [1] [2]