up
This commit is contained in:
@@ -1,17 +1,14 @@
|
||||
import inspect
|
||||
import logging
|
||||
import sys
|
||||
|
||||
from . import monkey
|
||||
|
||||
import logging
|
||||
import distutils.log
|
||||
from . import monkey
|
||||
|
||||
|
||||
def _not_warning(record):
|
||||
return record.levelno < logging.WARNING
|
||||
|
||||
|
||||
def configure() -> None:
|
||||
def configure():
|
||||
"""
|
||||
Configure logging to emit warning and above to stderr
|
||||
and everything else to stdout. This behavior is provided
|
||||
@@ -24,9 +21,8 @@ def configure() -> None:
|
||||
out_handler.addFilter(_not_warning)
|
||||
handlers = err_handler, out_handler
|
||||
logging.basicConfig(
|
||||
format="{message}", style='{', handlers=handlers, level=logging.DEBUG
|
||||
)
|
||||
if inspect.ismodule(distutils.dist.log):
|
||||
format="{message}", style='{', handlers=handlers, level=logging.DEBUG)
|
||||
if hasattr(distutils.log, 'Log'):
|
||||
monkey.patch_func(set_threshold, distutils.log, 'set_threshold')
|
||||
# For some reason `distutils.log` module is getting cached in `distutils.dist`
|
||||
# and then loaded again when patched,
|
||||
@@ -35,6 +31,6 @@ def configure() -> None:
|
||||
distutils.dist.log = distutils.log
|
||||
|
||||
|
||||
def set_threshold(level: int) -> int:
|
||||
logging.root.setLevel(level * 10)
|
||||
def set_threshold(level):
|
||||
logging.root.setLevel(level*10)
|
||||
return set_threshold.unpatched(level)
|
||||
|
||||
Reference in New Issue
Block a user