-
Notifications
You must be signed in to change notification settings - Fork 4
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
Using serializable.serializable_class
during import configures root logger
#9
Comments
I'll post a PR to fix this if the issue is approved or sits for a while. |
Ran into same issue today after spending time to find out where it happens. Issue is as described above in #9 (comment) - the library calls Another workaround for reconfiguring the root logger after the import of madpah/serializable/serializable/init.py is to use @kroeschl please go ahead for a PR to get this fixed |
serializable.serializable_class
during import configures root logger
Description
If some user of py-serializable calls
serializable.serializable_class
before configuring the root logger (which is common during import blocks), the root logger ends up configured with the default basic configuration.This happens because we call
logging.debug
inObjectMetadataLibrary.register_klass
. Callinglogging.debug
(or similar) will automatically calllogging.basicConfig
if no handlers are configured for the root logger.We should probably do what most modules do and set up our own logger and
NullHandler
rather than using the root logger.Example
Outputs
ERROR:root:foo
, which shouldn't happen if I only configure aNullHandler
.Workaround
I'm currently working around this by wrapping the import of anything that uses
py-serializable
(in this case, CycloneDX) in a logging configuration hack:Version Info
The text was updated successfully, but these errors were encountered: