summary refs log tree commit diff
path: root/synapse/logging/_structured.py
diff options
context:
space:
mode:
authorAmber Brown <hawkowl@atleastfornow.net>2019-11-26 03:45:50 +1100
committerGitHub <noreply@github.com>2019-11-26 03:45:50 +1100
commit9eebd46048d0b34767047b2156760a1467f19ae6 (patch)
tree1cd2d89c3eb04e04be784e942793c617bb4ff217 /synapse/logging/_structured.py
parentMerge pull request #6392 from matrix-org/babolivier/fix-1623 (diff)
downloadsynapse-9eebd46048d0b34767047b2156760a1467f19ae6.tar.xz
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(