Commit 9438116
authored
fix(logging): allow child loggers to set independent log levels
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>1 parent 6ae440a commit 9438116
1 file changed
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
242 | 242 | | |
243 | 243 | | |
244 | 244 | | |
245 | | - | |
| 245 | + | |
246 | 246 | | |
247 | 247 | | |
248 | 248 | | |
| |||
0 commit comments