summaryrefslogtreecommitdiff
path: root/src/wheel/_setuptools_logging.py
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2021-12-26 16:10:22 -0500
committerJason R. Coombs <jaraco@jaraco.com>2021-12-26 16:30:01 -0500
commit16326183595beb160242e954d9c30fad0c99e526 (patch)
tree959c348860552a4880167cf6a2fc8368fc682143 /src/wheel/_setuptools_logging.py
parent2540fef72bc680a0ed92a94d73bf01cdd30044fa (diff)
downloadwheel-git-python-logging-compat.tar.gz
Ensure logging is configured even on older Setuptools versions.python-logging-compat
Diffstat (limited to 'src/wheel/_setuptools_logging.py')
-rw-r--r--src/wheel/_setuptools_logging.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/wheel/_setuptools_logging.py b/src/wheel/_setuptools_logging.py
new file mode 100644
index 0000000..70efa06
--- /dev/null
+++ b/src/wheel/_setuptools_logging.py
@@ -0,0 +1,23 @@
+# copied from setuptools.logging, omitting monkeypatching
+import sys
+import logging
+
+
+def _not_warning(record):
+ return record.levelno < logging.WARNING
+
+
+def configure():
+ """
+ Configure logging to emit warning and above to stderr
+ and everything else to stdout. This behavior is provided
+ for compatibilty with distutils.log but may change in
+ the future.
+ """
+ err_handler = logging.StreamHandler()
+ err_handler.setLevel(logging.WARNING)
+ out_handler = logging.StreamHandler(sys.stdout)
+ out_handler.addFilter(_not_warning)
+ handlers = err_handler, out_handler
+ logging.basicConfig(
+ format="{message}", style='{', handlers=handlers, level=logging.DEBUG)