mypy: Fix logging.VDEBUG issues

This commit is contained in:
Florian Bruhin 2018-11-22 13:51:43 +01:00
parent 0999945af4
commit 4d1b3df5e0

View File

@ -76,12 +76,13 @@ LOG_COLORS = {
# We first monkey-patch logging to support our VDEBUG level before getting the
# loggers. Based on http://stackoverflow.com/a/13638084
# mypy doesn't know about this, so we need to ignore it.
VDEBUG_LEVEL = 9
logging.addLevelName(VDEBUG_LEVEL, 'VDEBUG')
logging.VDEBUG = VDEBUG_LEVEL
logging.VDEBUG = VDEBUG_LEVEL # type: ignore
LOG_LEVELS = {
'VDEBUG': logging.VDEBUG,
'VDEBUG': logging.VDEBUG, # type: ignore
'DEBUG': logging.DEBUG,
'INFO': logging.INFO,
'WARNING': logging.WARNING,
@ -89,17 +90,6 @@ LOG_LEVELS = {
'CRITICAL': logging.CRITICAL,
}
LOGGER_NAMES = [
'statusbar', 'completion', 'init', 'url',
'destroy', 'modes', 'webview', 'misc',
'mouse', 'procs', 'hints', 'keyboard',
'commands', 'signals', 'downloads',
'js', 'qt', 'rfc6266', 'ipc', 'shlexer',
'save', 'message', 'config', 'sessions',
'webelem', 'prompt', 'network', 'sql',
'greasemonkey'
]
def vdebug(self, msg, *args, **kwargs):
"""Log with a VDEBUG level.
@ -114,7 +104,7 @@ def vdebug(self, msg, *args, **kwargs):
# pylint: enable=protected-access
logging.Logger.vdebug = vdebug
logging.Logger.vdebug = vdebug # type: ignore
# The different loggers used.
@ -148,6 +138,17 @@ network = logging.getLogger('network')
sql = logging.getLogger('sql')
greasemonkey = logging.getLogger('greasemonkey')
LOGGER_NAMES = [
'statusbar', 'completion', 'init', 'url',
'destroy', 'modes', 'webview', 'misc',
'mouse', 'procs', 'hints', 'keyboard',
'commands', 'signals', 'downloads',
'js', 'qt', 'rfc6266', 'ipc', 'shlexer',
'save', 'message', 'config', 'sessions',
'webelem', 'prompt', 'network', 'sql',
'greasemonkey'
]
ram_handler = None
console_handler = None