diff --git a/radicale/__init__.py b/radicale/__init__.py index 85f5fbc..6dd9545 100644 --- a/radicale/__init__.py +++ b/radicale/__init__.py @@ -32,6 +32,7 @@ import pkg_resources from radicale import config, log from radicale.app import Application +from radicale.log import logger VERSION = pkg_resources.get_distribution("radicale").version @@ -53,7 +54,9 @@ def _init_application(config_path, wsgi_errors): config_path)) log.set_level(configuration.get("logging", "level")) # Log configuration after logger is configured - configuration.log_config_sources() + for source, miss in configuration.sources(): + logger.info("%s %s", "Skipped missing" if miss else "Loaded", + source) _application = Application(configuration) diff --git a/radicale/__main__.py b/radicale/__main__.py index e2ed260..991a66e 100644 --- a/radicale/__main__.py +++ b/radicale/__main__.py @@ -120,7 +120,8 @@ def run(): log.set_level(configuration.get("logging", "level")) # Log configuration after logger is configured - configuration.log_config_sources() + for source, miss in configuration.sources(): + logger.info("%s %s", "Skipped missing" if miss else "Loaded", source) if args.verify_storage: logger.info("Verifying storage") diff --git a/radicale/config.py b/radicale/config.py index a3ef92d..1f2df95 100644 --- a/radicale/config.py +++ b/radicale/config.py @@ -31,7 +31,6 @@ from collections import OrderedDict from configparser import RawConfigParser from radicale import auth, rights, storage, web -from radicale.log import logger DEFAULT_CONFIG_PATH = os.pathsep.join([ "?/etc/radicale/config", @@ -380,6 +379,11 @@ class Configuration: """List all options in ``section``""" return self._values[section].keys() + def sources(self): + """List all config sources.""" + return [(source, config is self.SOURCE_MISSING) for + config, source, _ in self._configs] + def copy(self, plugin_schema=None): """Create a copy of the configuration @@ -408,18 +412,3 @@ class Configuration: for config, source, internal in self._configs: copy.update(config, source, internal) return copy - - def log_config_sources(self): - """ - A helper function that writes a description of all config sources - to logger. - - Configs set to ``Configuration.SOURCE_MISSING`` are described as - missing. - - """ - for config, source, _ in self._configs: - if config is self.SOURCE_MISSING: - logger.info("Skipped missing %s", source) - else: - logger.info("Loaded %s", source)