Skip to content

[Bug] For some reason your module creates a handler(-s) for root logger #283

@Roman223

Description

@Roman223

Recently during work on another project I found that w/o implicit init of my logger it usually has strange handler in parent logger (root logger).

logger = get_logger("estimators", level=logging.DEBUG) # w/o clearing attributes with init
logger2 = Logger("estimators", level=logging.DEBUG) # w/ clearing

print(logger.handlers)
print(logger.parent)
print(logger.parent.handlers)
print("__")
print(logger2.handlers)
print(logger2.parent)

logger.info("test message")
print("separator")
logger2.info("test message")

Out:

[<RichHandler (NOTSET)>]
<RootLogger root (INFO)>
[<StreamHandler <stdout> (INFO)>, <RotatingFileHandler /tmp/GOLEM/log.log (INFO)>]
__
[<RichHandler (DEBUG)>]
None
[03/11/25 13:07:31] INFO     test message                   base_estimator.py:24
2025-03-11 13:07:31,646 - test message
separator
[03/11/25 13:07:31] INFO     test message                   base_estimator.py:26

This bug eventually leads to log duplication.

PS: For first time, there were 3 handlers, one from BAMT, but we do fix it by disabling formatter for root logger.

Metadata

Metadata

Assignees

Labels

bugSomething isn't workinginvalidThis doesn't seem right

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions