summary refs log tree commit diff
diff options
context:
space:
mode:
authorRichard van der Hoff <richard@matrix.org>2017-03-10 15:38:29 +0000
committerRichard van der Hoff <richard@matrix.org>2017-03-10 15:38:29 +0000
commitbcfa5cd00c4d5827a9a525078db32a0c93bc087c (patch)
tree87d1a439ee7e2bd97c27e0008e8955d593ae72ad
parentRefactor logger config for workers (diff)
downloadsynapse-bcfa5cd00c4d5827a9a525078db32a0c93bc087c.tar.xz
Add an option to disable stdio redirect
This makes it tractable to run synapse under pdb.
Diffstat (limited to '')
-rw-r--r--synapse/config/logger.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/synapse/config/logger.py b/synapse/config/logger.py
index c76fddf118..a48f7695ee 100644
--- a/synapse/config/logger.py
+++ b/synapse/config/logger.py
@@ -68,6 +68,7 @@ class LoggingConfig(Config):
 
     def read_config(self, config):
         self.verbosity = config.get("verbose", 0)
+        self.no_redirect_stdio = config.get("no_redirect_stdio", False)
         self.log_config = self.abspath(config.get("log_config"))
         self.log_file = self.abspath(config.get("log_file"))
 
@@ -90,6 +91,8 @@ class LoggingConfig(Config):
     def read_arguments(self, args):
         if args.verbose is not None:
             self.verbosity = args.verbose
+        if args.no_redirect_stdio is not None:
+            self.no_redirect_stdio = args.no_redirect_stdio
         if args.log_config is not None:
             self.log_config = args.log_config
         if args.log_file is not None:
@@ -109,6 +112,11 @@ class LoggingConfig(Config):
             '--log-config', dest="log_config", default=None,
             help="Python logging config file"
         )
+        logging_group.add_argument(
+            '-n', '--no-redirect-stdio',
+            action='store_true', default=None,
+            help="Do not redirect stdout/stderr to the log"
+        )
 
     def generate_files(self, config):
         log_config = config.get("log_config")
@@ -194,4 +202,7 @@ def setup_logging(config, use_worker_options=False):
     #
     # However this may not be too much of a problem if we are just writing to a file.
     observer = STDLibLogObserver()
-    globalLogBeginner.beginLoggingTo([observer])
+    globalLogBeginner.beginLoggingTo(
+        [observer],
+        redirectStandardIO=not config.no_redirect_stdio,
+    )