summary refs log tree commit diff
path: root/synapse/config
diff options
context:
space:
mode:
authorRichard van der Hoff <richard@matrix.org>2017-03-10 15:16:50 +0000
committerRichard van der Hoff <richard@matrix.org>2017-03-10 15:34:01 +0000
commitd84bd51e95149f67e0740657d60b568533a6ea72 (patch)
tree248717e8119a6b941fa5c33b930978a1c4184481 /synapse/config
parentFix docstring (diff)
downloadsynapse-d84bd51e95149f67e0740657d60b568533a6ea72.tar.xz
Refactor logger config for workers
- to make it easier to add more config options.
Diffstat (limited to 'synapse/config')
-rw-r--r--synapse/config/logger.py21
1 files changed, 16 insertions, 5 deletions
diff --git a/synapse/config/logger.py b/synapse/config/logger.py
index 77ded0ad25..c76fddf118 100644
--- a/synapse/config/logger.py
+++ b/synapse/config/logger.py
@@ -118,11 +118,22 @@ class LoggingConfig(Config):
                     DEFAULT_LOG_CONFIG.substitute(log_file=config["log_file"])
                 )
 
-    def setup_logging(self):
-        setup_logging(self.log_config, self.log_file, self.verbosity)
 
+def setup_logging(config, use_worker_options=False):
+    """ Set up python logging
+
+    Args:
+        config (LoggingConfig | synapse.config.workers.WorkerConfig):
+            configuration data
+
+        use_worker_options (bool): True to use 'worker_log_config' and
+            'worker_log_file' options instead of 'log_config' and 'log_file'.
+    """
+    log_config = (config.worker_log_config if use_worker_options
+                  else config.log_config)
+    log_file = (config.worker_log_file if use_worker_options
+                else config.log_file)
 
-def setup_logging(log_config=None, log_file=None, verbosity=None):
     log_format = (
         "%(asctime)s - %(name)s - %(lineno)d - %(levelname)s - %(request)s"
         " - %(message)s"
@@ -131,9 +142,9 @@ def setup_logging(log_config=None, log_file=None, verbosity=None):
 
         level = logging.INFO
         level_for_storage = logging.INFO
-        if verbosity:
+        if config.verbosity:
             level = logging.DEBUG
-            if verbosity > 1:
+            if config.verbosity > 1:
                 level_for_storage = logging.DEBUG
 
         # FIXME: we need a logging.WARN for a -q quiet option