Fix increasing of verbosity using loglevels config

This commit is contained in:
Thomas Adamcik 2014-02-06 23:18:25 +01:00 committed by Stein Magnus Jodal
parent cfd41771a6
commit 40cadbfa26
2 changed files with 13 additions and 2 deletions

View File

@ -8,6 +8,12 @@ This changelog is used to track all major changes to Mopidy.
v0.19.0 (unreleased)
====================
**Configuration**
- Fix the log setup so that it is possible to increase the amount of logging
from a specific logger using the ``loglevels`` config section. (Fixes:
:issue:`684`)
**Models**
- The type of :attr:`mopidy.models.Playlist.last_modified` has been redefined

View File

@ -62,10 +62,15 @@ LOG_LEVELS = {
class VerbosityFilter(logging.Filter):
def __init__(self, verbosity_level):
def __init__(self, verbosity_level, loglevels):
self.verbosity_level = verbosity_level
self.loglevels = loglevels
def filter(self, record):
for name, required_log_level in self.loglevels.items():
if record.name == name or record.name.startswith(name + '.'):
return record.levelno >= required_log_level
if record.name.startswith('mopidy'):
required_log_level = LOG_LEVELS[self.verbosity_level]['mopidy']
else:
@ -79,7 +84,7 @@ def setup_console_logging(config, verbosity_level):
if verbosity_level > max(LOG_LEVELS.keys()):
verbosity_level = max(LOG_LEVELS.keys())
verbosity_filter = VerbosityFilter(verbosity_level)
verbosity_filter = VerbosityFilter(verbosity_level, config['loglevels'])
if verbosity_level < 1:
log_format = config['logging']['console_format']