diff options
author | Richard van der Hoff <richard@matrix.org> | 2018-08-20 18:20:07 +0100 |
---|---|---|
committer | Richard van der Hoff <richard@matrix.org> | 2018-08-20 18:20:07 +0100 |
commit | 55e6bdf28798153de5c2a6cf9bf0a6618f59168a (patch) | |
tree | 21e7b2f9303aff50db85f7e5beec7a5dc61842f1 /synapse | |
parent | changelog (diff) | |
download | synapse-55e6bdf28798153de5c2a6cf9bf0a6618f59168a.tar.xz |
Robustness fix for logcontext filter
Make the logcontext filter not explode if it somehow ends up with a logcontext of None, since that infinite-loops the whole logging system.
Diffstat (limited to 'synapse')
-rw-r--r-- | synapse/util/logcontext.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/synapse/util/logcontext.py b/synapse/util/logcontext.py index 07e83fadda..848765e530 100644 --- a/synapse/util/logcontext.py +++ b/synapse/util/logcontext.py @@ -385,7 +385,13 @@ class LoggingContextFilter(logging.Filter): context = LoggingContext.current_context() for key, value in self.defaults.items(): setattr(record, key, value) - context.copy_to(record) + + # context should never be None, but if it somehow ends up being, then + # we end up in a death spiral of infinite loops, so let's check, for + # robustness' sake. + if context is not None: + context.copy_to(record) + return True |