logging.basicConfig(level=logging.DEBUG)
in the main script. This line sets up all the loggers from root onwards and sets them to a uniform level.
main.py
import logging import module as m logging.basicConfig(level=logging.DEBUG) logger = logging.getLogger(__name__) logger.warning('This is a warning from the main script') m.f1()
module.py import logging logger = logging.getLogger(__name__) def f1(): logger.info('A warning from the module')
No comments:
Post a Comment