Index: Lib/distutils/__init__.py =================================================================== --- Lib/distutils/__init__.py (révision 66676) +++ Lib/distutils/__init__.py (copie de travail) @@ -7,6 +7,8 @@ setup (...) """ +import logging +import sys # This module should be kept compatible with Python 2.1. @@ -20,7 +22,16 @@ # In general, major and minor version should loosely follow the Python # version number the distutils code was shipped with. # +logger = None +if logger is None: + logger = logging.getLogger('distutils') + formatter = logging.Formatter() + handler = logging.StreamHandler(sys.stdout) + handler.setFormatter(formatter) + logger.addHandler(handler) + logger.setLevel(logging.WARNING) + #--start constants-- __version__ = "2.6rc2" #--end constants-- Index: Lib/distutils/log.py =================================================================== --- Lib/distutils/log.py (révision 66676) +++ Lib/distutils/log.py (copie de travail) @@ -5,60 +5,27 @@ # The class here is styled after PEP 282 so that it could later be # replaced with a standard Python logging implementation. -DEBUG = 1 -INFO = 2 -WARN = 3 -ERROR = 4 -FATAL = 5 - import sys +import logging +from distutils import logger -class Log: +DEBUG = logging.DEBUG +INFO = logging.INFO +WARN = logging.WARNING +ERROR = logging.ERROR +FATAL = logging.CRITICAL - def __init__(self, threshold=WARN): - self.threshold = threshold +log = logger.log +debug = logger.debug +info = logger.info +warn = logger.warning +error = logger.error +fatal = logger.critical - def _log(self, level, msg, args): - if level >= self.threshold: - if not args: - # msg may contain a '%'. If args is empty, - # don't even try to string-format - print msg - else: - print msg % args - sys.stdout.flush() - - def log(self, level, msg, *args): - self._log(level, msg, args) - - def debug(self, msg, *args): - self._log(DEBUG, msg, args) - - def info(self, msg, *args): - self._log(INFO, msg, args) - - def warn(self, msg, *args): - self._log(WARN, msg, args) - - def error(self, msg, *args): - self._log(ERROR, msg, args) - - def fatal(self, msg, *args): - self._log(FATAL, msg, args) - -_global_log = Log() -log = _global_log.log -debug = _global_log.debug -info = _global_log.info -warn = _global_log.warn -error = _global_log.error -fatal = _global_log.fatal - def set_threshold(level): - # return the old threshold for use from tests - old = _global_log.threshold - _global_log.threshold = level - return old + old = logger.getEffectiveLevel() + logger.setLevel(level) + return old def set_verbosity(v): if v <= 0: @@ -67,3 +34,4 @@ set_threshold(INFO) elif v >= 2: set_threshold(DEBUG) + Index: Lib/distutils/tests/test_dist.py =================================================================== --- Lib/distutils/tests/test_dist.py (révision 66676) +++ Lib/distutils/tests/test_dist.py (copie de travail) @@ -11,7 +11,6 @@ from test.test_support import TESTFN - class test_dist(distutils.cmd.Command): """Sample distutils extension command.""" @@ -46,6 +45,7 @@ def create_distribution(self, configfiles=()): d = TestDistribution() + d.verbose = 0 d._config_files = configfiles d.parse_config_files() d.parse_command_line() Index: Lib/distutils/tests/test_build_py.py =================================================================== --- Lib/distutils/tests/test_build_py.py (révision 66676) +++ Lib/distutils/tests/test_build_py.py (copie de travail) @@ -78,6 +78,7 @@ # script_name need not exist, it just need to be initialized dist.script_name = os.path.join(sources, "setup.py") dist.script_args = ["build"] + dist.verbose = 0 dist.parse_command_line() try: