lazy_module changes root logger and thus affects programs importing it in undesired way.
The following snippet illustrates the issue:
import lazy_import
import logging
if __name__ == '__main__':
logger = logging.getLogger('dupa')
logging.basicConfig(
format='%(asctime)s ai [%(process)d] <%(levelname)s> '
'| %(module)s | %(processName)s | %(message)s',
datefmt='%Y-%m-%d %H:%M:%S',
level=logging.DEBUG
)
logger.info('DUPA')
Removing the import lazy_import restores desired default behavior.
lazy_import should use its own logger and refrain from calling logging.basicConfig().
As per https://docs.python.org/3/library/logging.html#logging.basicConfig
This function does nothing if the root logger already has handlers configured for it.
lazy_module changes root logger and thus affects programs importing it in undesired way.
The following snippet illustrates the issue:
Removing the
import lazy_importrestores desired default behavior.lazy_import should use its own logger and refrain from calling
logging.basicConfig().As per https://docs.python.org/3/library/logging.html#logging.basicConfig