Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/2974.change.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Setuptools now relies on the Python logging infrastructure to log messages. Instead of using ``distutils.log.*``, use ``logging.getLogger(name).*``.
2 changes: 2 additions & 0 deletions setuptools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from setuptools.dist import Distribution
from setuptools.depends import Require
from . import monkey
from . import logging


__all__ = [
Expand Down Expand Up @@ -149,6 +150,7 @@ def finalize_options(self):

def setup(**attrs):
# Make sure we have any requirements needed to interpret 'attrs'.
logging.configure()
Comment thread
jaraco marked this conversation as resolved.
_install_setup_requires(attrs)
return distutils.core.setup(**attrs)

Expand Down
30 changes: 30 additions & 0 deletions setuptools/logging.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import sys
import logging
import distutils.log
from . import monkey


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)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why default level is DEBUG instead of INFO or WARNING?

monkey.patch_func(set_threshold, distutils.log, 'set_threshold')


def set_threshold(level):
logging.root.setLevel(level*10)
return set_threshold.unpatched(level)