Drop debug2() (refs: #3304)

This commit is contained in:
Takeshi KOMIYA 2017-01-07 15:03:06 +09:00
parent 13df6f20ea
commit ae24524d5f
4 changed files with 19 additions and 47 deletions

View File

@ -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

View File

@ -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

View File

@ -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', {})

View File

@ -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):