summary refs log tree commit diff
path: root/synapse/config/logger.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2019-01-30 11:48:29 +0000
committerErik Johnston <erik@matrix.org>2019-01-30 11:48:29 +0000
commitd351be15670766d634b12f08483b3b4a750f76fb (patch)
tree0a58ea6f751407e66dd7b553e045a737c38e4667 /synapse/config/logger.py
parentMerge branch 'develop' of github.com:matrix-org/synapse into matrix-org-hotfixes (diff)
parentMerge pull request #4521 from matrix-org/rav/fed_routing/cleanups (diff)
downloadsynapse-d351be15670766d634b12f08483b3b4a750f76fb.tar.xz
Merge branch 'develop' of github.com:matrix-org/synapse into matrix-org-hotfixes
Diffstat (limited to 'synapse/config/logger.py')
-rw-r--r--synapse/config/logger.py19
1 files changed, 11 insertions, 8 deletions
diff --git a/synapse/config/logger.py b/synapse/config/logger.py

index f87efecbf8..a795e39b1a 100644 --- a/synapse/config/logger.py +++ b/synapse/config/logger.py
@@ -127,7 +127,7 @@ class LoggingConfig(Config): ) -def setup_logging(config, use_worker_options=False): +def setup_logging(config, use_worker_options=False, register_sighup=None): """ Set up python logging Args: @@ -136,7 +136,16 @@ def setup_logging(config, use_worker_options=False): use_worker_options (bool): True to use 'worker_log_config' and 'worker_log_file' options instead of 'log_config' and 'log_file'. + + register_sighup (func | None): Function to call to register a + sighup handler. """ + if not register_sighup: + if getattr(signal, "SIGHUP"): + register_sighup = lambda x: signal.signal(signal.SIGHUP, x) + else: + register_sighup = lambda x: None + log_config = (config.worker_log_config if use_worker_options else config.log_config) log_file = (config.worker_log_file if use_worker_options @@ -198,13 +207,7 @@ def setup_logging(config, use_worker_options=False): load_log_config() - # TODO(paul): obviously this is a terrible mechanism for - # stealing SIGHUP, because it means no other part of synapse - # can use it instead. If we want to catch SIGHUP anywhere - # else as well, I'd suggest we find a nicer way to broadcast - # it around. - if getattr(signal, "SIGHUP"): - signal.signal(signal.SIGHUP, sighup) + register_sighup(sighup) # make sure that the first thing we log is a thing we can grep backwards # for