config: Add logging/config_file
This commit is contained in:
parent
c6490afc2d
commit
18ebb56b3e
@ -97,6 +97,12 @@ Core configuration values
|
|||||||
The file to dump debug log data to when Mopidy is run with the
|
The file to dump debug log data to when Mopidy is run with the
|
||||||
:option:`mopidy --save-debug-log` option.
|
:option:`mopidy --save-debug-log` option.
|
||||||
|
|
||||||
|
.. confval:: logging/config_file
|
||||||
|
|
||||||
|
Config file that overrides all logging settings, see `the Python
|
||||||
|
logging docs <http://docs.python.org/2/library/logging.config.html>`_
|
||||||
|
for details.
|
||||||
|
|
||||||
.. confval:: loglevels/*
|
.. confval:: loglevels/*
|
||||||
|
|
||||||
The ``loglevels`` config section can be used to change the log level for
|
The ``loglevels`` config section can be used to change the log level for
|
||||||
|
|||||||
@ -15,6 +15,7 @@ _logging_schema = ConfigSchema('logging')
|
|||||||
_logging_schema['console_format'] = String()
|
_logging_schema['console_format'] = String()
|
||||||
_logging_schema['debug_format'] = String()
|
_logging_schema['debug_format'] = String()
|
||||||
_logging_schema['debug_file'] = Path()
|
_logging_schema['debug_file'] = Path()
|
||||||
|
_logging_schema['config_file'] = Path(optional=True)
|
||||||
|
|
||||||
_loglevels_schema = LogLevelConfigSchema('loglevels')
|
_loglevels_schema = LogLevelConfigSchema('loglevels')
|
||||||
|
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
console_format = %(levelname)-8s %(message)s
|
console_format = %(levelname)-8s %(message)s
|
||||||
debug_format = %(levelname)-8s %(asctime)s [%(process)d:%(threadName)s] %(name)s\n %(message)s
|
debug_format = %(levelname)-8s %(asctime)s [%(process)d:%(threadName)s] %(name)s\n %(message)s
|
||||||
debug_file = mopidy.log
|
debug_file = mopidy.log
|
||||||
|
config_file =
|
||||||
|
|
||||||
[loglevels]
|
[loglevels]
|
||||||
pykka = info
|
pykka = info
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
import logging.config
|
||||||
import logging.handlers
|
import logging.handlers
|
||||||
|
|
||||||
from . import versioning
|
from . import versioning
|
||||||
@ -15,6 +16,9 @@ def setup_logging(config, verbosity_level, save_debug_log):
|
|||||||
# New in Python 2.7
|
# New in Python 2.7
|
||||||
logging.captureWarnings(True)
|
logging.captureWarnings(True)
|
||||||
|
|
||||||
|
if config['logging']['config_file']:
|
||||||
|
logging.config.fileConfig(config['logging']['config_file'])
|
||||||
|
|
||||||
logger = logging.getLogger('mopidy.utils.log')
|
logger = logging.getLogger('mopidy.utils.log')
|
||||||
logger.info('Starting Mopidy %s', versioning.get_version())
|
logger.info('Starting Mopidy %s', versioning.get_version())
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user