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