diff --git a/docs/changelog.rst b/docs/changelog.rst index 5581bfec..413e2ca9 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -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: diff --git a/mopidy/utils/log.py b/mopidy/utils/log.py index 396c05b9..79ec723c 100644 --- a/mopidy/utils/log.py +++ b/mopidy/utils/log.py @@ -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),