Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Root logger conflict with my custom logging structure #1867

Closed
Raverss opened this issue Aug 7, 2024 · 2 comments · Fixed by #1868
Closed

Root logger conflict with my custom logging structure #1867

Raverss opened this issue Aug 7, 2024 · 2 comments · Fixed by #1868
Labels
bug Something isn't working

Comments

@Raverss
Copy link

Raverss commented Aug 7, 2024

The root logger setup in the version check interferes with the custom logging structure. For example, let's assume that I'm making my own Python package where a top-level logger is setup in the init.py of the package, and loggers in the sub-packages inherit from this top-level logger. The top-level logger adds a stream handler. If Albumentations is imported somewhere in the package it will override/setup the root logger with a different stream handler and all the loggers will log twice.

Please do not use the BasicConfig() function and instead manually add the handler to your logger.

This is the line in question

If anybody has the same issue, the workaround is to always check and remove handlers from the root logger (you are most likely not using the root logger anyway) when creating a new logger:

for handler in logging.root.handlers[:]:
    logging.root.removeHandler(handler)
@ternaus
Copy link
Collaborator

ternaus commented Aug 7, 2024

Thanks, good point. Working on it.

@ternaus ternaus added the bug Something isn't working label Aug 7, 2024
@ternaus
Copy link
Collaborator

ternaus commented Aug 7, 2024

@Raverss thanks for the report. Addressed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants