log: Define TRACE log level with name and color

This commit is contained in:
Stein Magnus Jodal 2015-02-12 18:03:13 +01:00
parent df67d708db
commit 79dbc652e0
2 changed files with 11 additions and 0 deletions

View File

@ -32,6 +32,11 @@ v0.20.0 (UNRELEASED)
This can be used to show absolutely all log records, including those at
custom levels below ``DEBUG``.
**Logging**
- Add custom log level ``TRACE`` (numerical level 5), which can be used by
Mopidy and extensions to log at an even more detailed level than ``DEBUG``.
**Local backend**
- Add cover URL to all scanned files with MusicBrainz album IDs. (Fixes:

View File

@ -14,6 +14,9 @@ LOG_LEVELS = {
3: dict(root=logging.DEBUG, mopidy=logging.DEBUG),
}
# Custom log level which has even lower priority than DEBUG
TRACE_LOG_LEVEL = 5
class DelayedHandler(logging.Handler):
def __init__(self):
@ -42,6 +45,8 @@ def bootstrap_delayed_logging():
def setup_logging(config, verbosity_level, save_debug_log):
logging.addLevelName(TRACE_LOG_LEVEL, 'TRACE')
logging.captureWarnings(True)
if config['logging']['config_file']:
@ -137,6 +142,7 @@ class ColorizingStreamHandler(logging.StreamHandler):
# Map logging levels to (background, foreground, bold/intense)
level_map = {
TRACE_LOG_LEVEL: (None, 'blue', False),
logging.DEBUG: (None, 'blue', False),
logging.INFO: (None, 'white', False),
logging.WARNING: (None, 'yellow', False),