Path: blob/main/test/lib/python3.9/site-packages/setuptools/logging.py
4798 views
import sys1import logging2import distutils.log3from . import monkey456def _not_warning(record):7return record.levelno < logging.WARNING8910def configure():11"""12Configure logging to emit warning and above to stderr13and everything else to stdout. This behavior is provided14for compatibilty with distutils.log but may change in15the future.16"""17err_handler = logging.StreamHandler()18err_handler.setLevel(logging.WARNING)19out_handler = logging.StreamHandler(sys.stdout)20out_handler.addFilter(_not_warning)21handlers = err_handler, out_handler22logging.basicConfig(23format="{message}", style='{', handlers=handlers, level=logging.DEBUG)24monkey.patch_func(set_threshold, distutils.log, 'set_threshold')2526# For some reason `distutils.log` module is getting cached in `distutils.dist`27# and then loaded again when patched,28# implying: id(distutils.log) != id(distutils.dist.log).29# Make sure the same module object is used everywhere:30distutils.dist.log = distutils.log313233def set_threshold(level):34logging.root.setLevel(level*10)35return set_threshold.unpatched(level)363738