From ae24524d5f95cb7c94ffb2404322f1d0c0e4a6e1 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Sat, 7 Jan 2017 15:03:06 +0900 Subject: [PATCH] Drop debug2() (refs: #3304) --- sphinx/application.py | 4 +-- sphinx/ext/autodoc.py | 2 +- sphinx/util/logging.py | 8 ------ tests/test_util_logging.py | 52 ++++++++++++-------------------------- 4 files changed, 19 insertions(+), 47 deletions(-) diff --git a/sphinx/application.py b/sphinx/application.py index 307d63073..d6b781f59 100644 --- a/sphinx/application.py +++ b/sphinx/application.py @@ -425,9 +425,9 @@ class Sphinx(object): def debug2(self, message, *args, **kwargs): # type: (unicode, Any, Any) -> None """Emit a lowlevel debug-level informational message.""" - warnings.warn('app.debug2() is now deprecated. Use sphinx.util.logging instead.', + warnings.warn('app.debug2() is now deprecated. Use debug() instead.', RemovedInSphinx20Warning) - logger.debug2(message, *args, **kwargs) + logger.debug(message, *args, **kwargs) def _display_chunk(chunk): # type: (Any) -> unicode diff --git a/sphinx/ext/autodoc.py b/sphinx/ext/autodoc.py index 3e7f84b8e..01ced26de 100644 --- a/sphinx/ext/autodoc.py +++ b/sphinx/ext/autodoc.py @@ -1762,7 +1762,7 @@ class AutoDirective(Directive): if not self.result: return self.warnings - logger.debug2('[autodoc] output:\n%s', '\n'.join(self.result)) + logger.debug('[autodoc] output:\n%s', '\n'.join(self.result)) # record all filenames as dependencies -- this will at least # partially make automatic invalidation possible diff --git a/sphinx/util/logging.py b/sphinx/util/logging.py index eb9c03ff3..b4f8f5796 100644 --- a/sphinx/util/logging.py +++ b/sphinx/util/logging.py @@ -30,7 +30,6 @@ if False: VERBOSE = 15 -DEBUG2 = 5 LEVEL_NAMES = defaultdict(lambda: logging.WARNING) # type: Dict[str, int] LEVEL_NAMES.update({ @@ -41,7 +40,6 @@ LEVEL_NAMES.update({ 'INFO': logging.INFO, 'VERBOSE': VERBOSE, 'DEBUG': logging.DEBUG, - 'DEBUG2': DEBUG2, }) VERBOSITY_MAP = defaultdict(lambda: 0) # type: Dict[int, int] @@ -49,14 +47,12 @@ VERBOSITY_MAP.update({ 0: logging.INFO, 1: VERBOSE, 2: logging.DEBUG, - 3: DEBUG2, }) COLOR_MAP = defaultdict(lambda text: text) # type: Dict[int, unicode] COLOR_MAP.update({ logging.WARNING: 'darkred', logging.DEBUG: 'darkgray', - DEBUG2: 'lightgray', }) @@ -105,10 +101,6 @@ class SphinxLoggerAdapter(logging.LoggerAdapter): # type: (unicode, Any, Any) -> None self.log(VERBOSE, msg, *args, **kwargs) - def debug2(self, msg, *args, **kwargs): - # type: (unicode, Any, Any) -> None - self.log(DEBUG2, msg, *args, **kwargs) - def process(self, msg, kwargs): # type: ignore # type: (unicode, Dict) -> Tuple[unicode, Dict] extra = kwargs.setdefault('extra', {}) diff --git a/tests/test_util_logging.py b/tests/test_util_logging.py index b3e65e1e3..4083ec5bd 100644 --- a/tests/test_util_logging.py +++ b/tests/test_util_logging.py @@ -24,7 +24,7 @@ from util import strip_escseq def test_info_and_warning(app, status, warning): - app.verbosity = 3 + app.verbosity = 2 logging.setup(app, status, warning) logger = logging.getLogger(__name__) @@ -56,7 +56,6 @@ def test_verbosity_filter(app, status, warning): logger.info('message1') logger.verbose('message2') logger.debug('message3') - logger.debug2('message4') assert 'message1' in status.getvalue() assert 'message2' not in status.getvalue() @@ -71,7 +70,6 @@ def test_verbosity_filter(app, status, warning): logger.info('message1') logger.verbose('message2') logger.debug('message3') - logger.debug2('message4') assert 'message1' in status.getvalue() assert 'message2' in status.getvalue() @@ -86,28 +84,12 @@ def test_verbosity_filter(app, status, warning): logger.info('message1') logger.verbose('message2') logger.debug('message3') - logger.debug2('message4') assert 'message1' in status.getvalue() assert 'message2' in status.getvalue() assert 'message3' in status.getvalue() assert 'message4' not in status.getvalue() - # verbosity = 3: DEBUG2 - app.verbosity = 3 - logging.setup(app, status, warning) - logger = logging.getLogger(__name__) - - logger.info('message1') - logger.verbose('message2') - logger.debug('message3') - logger.debug2('message4') - - assert 'message1' in status.getvalue() - assert 'message2' in status.getvalue() - assert 'message3' in status.getvalue() - assert 'message4' in status.getvalue() - def test_nonl_info_log(app, status, warning): logging.setup(app, status, warning) @@ -233,32 +215,30 @@ def test_pending_warnings(app, status, warning): def test_colored_logs(app, status, warning): - app.verbosity = 3 + app.verbosity = 2 logging.setup(app, status, warning) logger = logging.getLogger(__name__) # default colors - logger.debug2('message1') - logger.debug('message2') - logger.verbose('message3') - logger.info('message4') - logger.warning('message5') - logger.critical('message6') - logger.error('message7') + logger.debug('message1') + logger.verbose('message2') + logger.info('message3') + logger.warning('message4') + logger.critical('message5') + logger.error('message6') - assert colorize('lightgray', 'message1') in status.getvalue() - assert colorize('darkgray', 'message2') in status.getvalue() + assert colorize('darkgray', 'message1') in status.getvalue() + assert 'message2\n' in status.getvalue() # not colored assert 'message3\n' in status.getvalue() # not colored - assert 'message4\n' in status.getvalue() # not colored - assert colorize('darkred', 'WARNING: message5') in warning.getvalue() + assert colorize('darkred', 'WARNING: message4') in warning.getvalue() + assert 'WARNING: message5\n' in warning.getvalue() # not colored assert 'WARNING: message6\n' in warning.getvalue() # not colored - assert 'WARNING: message7\n' in warning.getvalue() # not colored # color specification - logger.debug('message8', color='white') - logger.info('message9', color='red') - assert colorize('white', 'message8') in status.getvalue() - assert colorize('red', 'message9') in status.getvalue() + logger.debug('message7', color='white') + logger.info('message8', color='red') + assert colorize('white', 'message7') in status.getvalue() + assert colorize('red', 'message8') in status.getvalue() def test_logging_in_ParallelTasks(app, status, warning):