Skip to content

lazy_module breaks logging #8

Description

@emsi

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions