Skip to content

feat: enhance logger_loader initialization with dynamic configuration - #88

Merged
bybatkhuu merged 1 commit into
mainfrom
dev
Aug 27, 2026
Merged

feat: enhance logger_loader initialization with dynamic configuration#88
bybatkhuu merged 1 commit into
mainfrom
dev

Conversation

@bybatkhuu

Copy link
Copy Markdown
Owner

This pull request updates the initialization logic for LoggerLoader in src/beans_logging/auto.py to allow dynamic control over log colorization based on the BEANS_LOGGING_AUTO_COLORIZED environment 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:

  • Added logic to read the BEANS_LOGGING_AUTO_COLORIZED environment variable and determine whether log colorization should be enabled or disabled.
  • If colorization is disabled, the logger configuration is updated to set colorize: False for the default handler (DEFAULT_STD_HANDLER_NAME).

Code refactoring:

  • Refactored the instantiation of LoggerLoader to use keyword arguments based on the environment-driven configuration.

@bybatkhuu bybatkhuu self-assigned this Aug 27, 2026
Copilot AI lite review requested due to automatic review settings August 27, 2026 07:36
@bybatkhuu bybatkhuu added the feature [✨ Features] MINOR version label Aug 27, 2026
@bybatkhuu
bybatkhuu merged commit 13168a3 into main Aug 27, 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.

🟡 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_COLORIZED from the environment and interpret it as a boolean.
  • When disabled, attempt to adjust the default STD handler configuration to set colorize=False.
  • Refactor LoggerLoader instantiation 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 thread src/beans_logging/auto.py
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}}}
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