python (3.11.7)

(root)/
lib/
python3.11/
site-packages/
setuptools/
logging.py
       1  import sys
       2  import logging
       3  import distutils.log
       4  from . import monkey
       5  
       6  
       7  def _not_warning(record):
       8      return record.levelno < logging.WARNING
       9  
      10  
      11  def configure():
      12      """
      13      Configure logging to emit warning and above to stderr
      14      and everything else to stdout. This behavior is provided
      15      for compatibility with distutils.log but may change in
      16      the future.
      17      """
      18      err_handler = logging.StreamHandler()
      19      err_handler.setLevel(logging.WARNING)
      20      out_handler = logging.StreamHandler(sys.stdout)
      21      out_handler.addFilter(_not_warning)
      22      handlers = err_handler, out_handler
      23      logging.basicConfig(
      24          format="{message}", style='{', handlers=handlers, level=logging.DEBUG)
      25      if hasattr(distutils.log, 'Log'):
      26          monkey.patch_func(set_threshold, distutils.log, 'set_threshold')
      27          # For some reason `distutils.log` module is getting cached in `distutils.dist`
      28          # and then loaded again when patched,
      29          # implying: id(distutils.log) != id(distutils.dist.log).
      30          # Make sure the same module object is used everywhere:
      31          distutils.dist.log = distutils.log
      32  
      33  
      34  def set_threshold(level):
      35      logging.root.setLevel(level*10)
      36      return set_threshold.unpatched(level)