Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix(logging): allow child loggers to set independent log levels#1077

Open
ThomasFarstrike wants to merge 1 commit intomicropython:master from
ThomasFarstrike:patch-2
Open

fix(logging): allow child loggers to set independent log levels #1077
ThomasFarstrike wants to merge 1 commit intomicropython:master from
ThomasFarstrike:patch-2

Conversation

@ThomasFarstrike
Copy link
Contributor

@ThomasFarstrike ThomasFarstrike commented Jan 26, 2026

The handler's level was being set to the root logger's level in basicConfig(), which prevented child loggers from setting their own levels. This violated the standard logging architecture where handlers should not filter by level - that's the logger's responsibility.

Changed handler.setLevel(level) to handler.setLevel(NOTSET) in basicConfig() so that handlers pass through all messages and let loggers control filtering.

This allows code like:
logger = logging.getLogger("myapp")
logger.setLevel(logging.INFO)
logger.info("message") # Now works correctly

Previously, INFO messages would be filtered out if the root logger was at WARNING.

Fixes: Child loggers unable to log at levels lower than root logger's level

The handler's level was being set to the root logger's level in basicConfig(),
which prevented child loggers from setting their own levels. This violated the
standard logging architecture where handlers should not filter by level - that's
the logger's responsibility.
Changed handler.setLevel(level) to handler.setLevel(NOTSET) in basicConfig()
so that handlers pass through all messages and let loggers control filtering.
This allows code like:
 logger = logging.getLogger("myapp")
 logger.setLevel(logging.INFO)
 logger.info("message") # Now works correctly
Previously, INFO messages would be filtered out if the root logger was at WARNING.
Fixes: Child loggers unable to log at levels lower than root logger's level
Signed-off-by: Thomas Farstrike <111072251+ThomasFarstrike@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

1 participant

Comments

AltStyle によって変換されたページ (->オリジナル) /