Add a VDEBUG logging level.
This commit is contained in:
parent
5176dac391
commit
f44896cc44
@ -66,8 +66,8 @@ def set_register_stylesheet(obj):
|
|||||||
Must have a STYLESHEET attribute.
|
Must have a STYLESHEET attribute.
|
||||||
"""
|
"""
|
||||||
qss = get_stylesheet(obj.STYLESHEET)
|
qss = get_stylesheet(obj.STYLESHEET)
|
||||||
log.style.debug("stylesheet for {}: {}".format(obj.__class__.__name__,
|
log.style.vdebug("stylesheet for {}: {}".format(
|
||||||
utils.compact_text(qss)))
|
obj.__class__.__name__, qss))
|
||||||
obj.setStyleSheet(qss)
|
obj.setStyleSheet(qss)
|
||||||
config.instance().changed.connect(
|
config.instance().changed.connect(
|
||||||
functools.partial(_update_stylesheet, obj))
|
functools.partial(_update_stylesheet, obj))
|
||||||
|
@ -70,6 +70,7 @@ EXTENDED_FMT_HTML = (
|
|||||||
)
|
)
|
||||||
DATEFMT = '%H:%M:%S'
|
DATEFMT = '%H:%M:%S'
|
||||||
LOG_COLORS = {
|
LOG_COLORS = {
|
||||||
|
'VDEBUG': 'white',
|
||||||
'DEBUG': 'white',
|
'DEBUG': 'white',
|
||||||
'INFO': 'green',
|
'INFO': 'green',
|
||||||
'WARNING': 'yellow',
|
'WARNING': 'yellow',
|
||||||
@ -78,8 +79,29 @@ LOG_COLORS = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# The different loggers used.
|
# We first monkey-patch logging to support our VDEBUG level before getting the
|
||||||
|
# loggers. Based on http://stackoverflow.com/a/13638084
|
||||||
|
VDEBUG_LEVEL = 9
|
||||||
|
logging.addLevelName(VDEBUG_LEVEL, 'VDEBUG')
|
||||||
|
logging.VDEBUG = VDEBUG_LEVEL
|
||||||
|
|
||||||
|
|
||||||
|
def vdebug(self, message, *args, **kwargs):
|
||||||
|
"""Log with a VDEBUG level.
|
||||||
|
|
||||||
|
VDEBUG is used when a debug message is rather verbose, and probably of
|
||||||
|
little use to the end user or for post-mortem debugging, i.e. the content
|
||||||
|
probably won't change unless the code changes.
|
||||||
|
"""
|
||||||
|
if self.isEnabledFor(VDEBUG_LEVEL):
|
||||||
|
# pylint: disable=protected-access
|
||||||
|
self._log(VDEBUG_LEVEL, message, args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
|
logging.Logger.vdebug = vdebug
|
||||||
|
|
||||||
|
|
||||||
|
# The different loggers used.
|
||||||
statusbar = logging.getLogger('statusbar')
|
statusbar = logging.getLogger('statusbar')
|
||||||
completion = logging.getLogger('completion')
|
completion = logging.getLogger('completion')
|
||||||
destroy = logging.getLogger('destroy')
|
destroy = logging.getLogger('destroy')
|
||||||
@ -106,7 +128,7 @@ ram_handler = None
|
|||||||
|
|
||||||
def init_log(args):
|
def init_log(args):
|
||||||
"""Init loggers based on the argparse namespace passed."""
|
"""Init loggers based on the argparse namespace passed."""
|
||||||
level = 'DEBUG' if args.debug else args.loglevel.upper()
|
level = 'VDEBUG' if args.debug else args.loglevel.upper()
|
||||||
try:
|
try:
|
||||||
numeric_level = getattr(logging, level)
|
numeric_level = getattr(logging, level)
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
@ -314,7 +336,9 @@ class RAMHandler(logging.Handler):
|
|||||||
self.data = collections.deque()
|
self.data = collections.deque()
|
||||||
|
|
||||||
def emit(self, record):
|
def emit(self, record):
|
||||||
self.data.append(record)
|
if record.levelno >= logging.DEBUG:
|
||||||
|
# We don't log VDEBUG to RAM.
|
||||||
|
self.data.append(record)
|
||||||
|
|
||||||
def dump_log(self, html=False):
|
def dump_log(self, html=False):
|
||||||
"""Dump the complete formatted log data as as string."""
|
"""Dump the complete formatted log data as as string."""
|
||||||
|
Loading…
Reference in New Issue
Block a user