Skip to content

Enhance logging configuration with dynamic level settings - #91

Merged
bybatkhuu merged 2 commits into
mainfrom
dev
Sep 14, 2026
Merged

Enhance logging configuration with dynamic level settings#91
bybatkhuu merged 2 commits into
mainfrom
dev

Conversation

@bybatkhuu

Copy link
Copy Markdown
Owner

This pull request introduces support for configuring the logging behavior of the beans_logging.auto module 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:

  • Added support for configuring log level (BEANS_LOGGING_AUTO_LEVEL), colorization (BEANS_LOGGING_AUTO_COLORIZED), and log format (BEANS_LOGGING_AUTO_FORMAT) through environment variables in beans_logging/auto.py. These are now read at runtime and applied to the logging handler configuration. [1] [2]

Documentation updates:

  • Updated .env.example and the logger section of README.md to include commented examples of the new logging-related environment variables, helping users understand available options and their usage. [1] [2]

@bybatkhuu bybatkhuu self-assigned this Sep 14, 2026
@bybatkhuu bybatkhuu added the feature [✨ Features] MINOR version label Sep 14, 2026
Copilot AI lite review requested due to automatic review settings September 14, 2026 13:17
@bybatkhuu
bybatkhuu merged commit dc0156a into main Sep 14, 2026
2 checks passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 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.md and .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.py puts the value under format_ in the serialized handlers config, while LoggerConfigPM serializes the default as format and LogHandlerPM gives 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.py puts the value under format_ in the serialized handlers config, while LoggerConfigPM serializes the default as format and LogHandlerPM gives 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 colorize when the parsed value is false, so BEANS_LOGGING_AUTO_COLORIZED=true produces no override. If the existing std_handler configuration has colorize: 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) calls load(load_config_file=True). _load_config_file() then merges configs/logger.yml on top of the current config, so the documented/template format and colorize values (and any configured handler level) 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature [✨ Features] MINOR version

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants