Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backfill distutils.log.Log for compatibility #192

Merged
merged 2 commits into from
Nov 22, 2022
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
19 changes: 19 additions & 0 deletions distutils/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"""

import logging
import warnings

from ._log import log as _global_log

Expand Down Expand Up @@ -36,3 +37,21 @@ def set_verbosity(v):
set_threshold(logging.INFO)
elif v >= 2:
set_threshold(logging.DEBUG)


class Log(logging.Logger):
"""distutils.log.Log is deprecated, please use an alternative from `logging`."""

def __init__(self, threshold=WARN):
warnings.warn(Log.__doc__) # avoid DeprecationWarning to ensure warn is shown
super().__init__(__name__, level=threshold)

@property
def threshold(self):
return self.level

@threshold.setter
def threshold(self, level):
self.setLevel(level)

warn = logging.Logger.warning
3 changes: 3 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,6 @@ filterwarnings=

# suppress warnings in deprecated compilers
ignore:(bcpp|msvc9?)compiler is deprecated

# suppress well know deprecation warning
ignore:distutils.log.Log is deprecated