-
Notifications
You must be signed in to change notification settings - Fork 37
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
Logger config overrides client logger config #238
Comments
Could you see if #241 fixes the issue? Unfortunately, I can't reproduce your issue! Here's what I tried: scratch_12.py #!/usr/bin/env python3
import logging
import genomepy
logging.basicConfig(level=logging.INFO, format="This is a logger message: %(message)s")
# promts a message
genomepy.manage_config("generate")
LOGGER = logging.getLogger("my_script")
LOGGER.info("Log message") |
Strange... With the exact same script I get the following output: Created config file /home/uniqueg/.config/genomepy/genomepy.yaml
INFO:my_script:Log message I'm at the airport, so no chance to try the PR right now, but will report back when I find the time. Thanks a lot. |
Note that I installed |
When installing dependencies via Mamba and then installing However, the situation is a little different, so I cannot say for sure whether it will fix the problem in the |
In fact, when I check out the |
I'm hoping the new version magically fixes this 🤞 |
Problem
When importing
genomepy
before setting a host application'slogger
config,genomepy
's logging configuration is used instead.Similar issues in other packages:
To reproduce
Put the following in a script:
Running the script yields:
Log message
Rerunning the script after removing the
import genomepy
line (or moving it after thelogging.basicConfig() call
) yields:INFO:my_script:Log message
Expected result
Importing a package should not affect the host application's logging configuration, even when it is imported before the host logger is configured.
Possible resolution
Instead of configuring the
genomepy
logger configuration in the library, consider configuring it in the CLI entry point (modulegenomepy.cli
) instead. That way, host applications consuminggenomepy
can configure their logger any way they want, while your intended logging behavior is set for users of thegenomepy
console script.Workaround
A workaround is to import
genomepy
after configuring the host application's logger.System info
OS version: Ubuntu 20.04.5 LTS
Python version: 3.7.12
genomepy version: 0.15.0
The text was updated successfully, but these errors were encountered: