diff options
author | Erik Johnston <erik@matrix.org> | 2016-02-10 11:23:32 +0000 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2016-02-10 11:23:32 +0000 |
commit | 9777c5f49ab354206f5aaecdc20880fbb8b17660 (patch) | |
tree | de51186934a36ace496b7448ce3d7326d8c607bb | |
parent | Fix test (diff) | |
download | synapse-9777c5f49ab354206f5aaecdc20880fbb8b17660.tar.xz |
Set parent context on instansiation
Diffstat (limited to '')
-rw-r--r-- | synapse/util/logcontext.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/synapse/util/logcontext.py b/synapse/util/logcontext.py index 301b30d58a..ffab03819d 100644 --- a/synapse/util/logcontext.py +++ b/synapse/util/logcontext.py @@ -79,7 +79,7 @@ class LoggingContext(object): sentinel = Sentinel() def __init__(self, name=None): - self.parent_context = None + self.parent_context = LoggingContext.current_context() self.name = name self.ru_stime = 0. self.ru_utime = 0. @@ -116,7 +116,12 @@ class LoggingContext(object): def __enter__(self): """Enters this logging context into thread local storage""" - self.parent_context = self.set_current_context(self) + old_context = self.set_current_context(self) + if self.parent_context != old_context: + logger.warn( + "Expected parent context %r, found %r", + self.parent_context, old_context + ) self.alive = True return self |