summary refs log tree commit diff
path: root/synapse/logging/_structured.py
diff options
context:
space:
mode:
authorAndrew Morgan <andrew@amorgan.xyz>2020-03-18 16:32:40 +0000
committerAndrew Morgan <andrew@amorgan.xyz>2020-03-18 16:32:40 +0000
commit0f54acfe259f10186eb9a400b6f1b974e4a08257 (patch)
tree3d78fe9b47e8b5aa034734a695aa1454887b5887 /synapse/logging/_structured.py
parent1.6.0rc2 (diff)
parentImprove the performance of structured logging (#6322) (diff)
downloadsynapse-0f54acfe259f10186eb9a400b6f1b974e4a08257.tar.xz
Improve the performance of structured logging (#6322)
* commit '9eebd4604':
  Improve the performance of structured logging (#6322)
Diffstat (limited to 'synapse/logging/_structured.py')
-rw-r--r--synapse/logging/_structured.py14
1 files changed, 13 insertions, 1 deletions
diff --git a/synapse/logging/_structured.py b/synapse/logging/_structured.py

index 334ddaf39a..ffa7b20ca8 100644 --- a/synapse/logging/_structured.py +++ b/synapse/logging/_structured.py
@@ -261,6 +261,18 @@ def parse_drain_configs( ) +class StoppableLogPublisher(LogPublisher): + """ + A log publisher that can tell its observers to shut down any external + communications. + """ + + def stop(self): + for obs in self._observers: + if hasattr(obs, "stop"): + obs.stop() + + def setup_structured_logging( hs, config, @@ -336,7 +348,7 @@ def setup_structured_logging( # We should never get here, but, just in case, throw an error. raise ConfigError("%s drain type cannot be configured" % (observer.type,)) - publisher = LogPublisher(*observers) + publisher = StoppableLogPublisher(*observers) log_filter = LogLevelFilterPredicate() for namespace, namespace_config in log_config.get(