diff options
author | Andrew Morgan <andrew@amorgan.xyz> | 2019-09-03 20:46:42 +0100 |
---|---|---|
committer | Andrew Morgan <andrew@amorgan.xyz> | 2019-09-03 20:46:42 +0100 |
commit | d9d156b5cdfe340a9b9c53b4002e5a14c5e9d68b (patch) | |
tree | f44b103aabcb58979d5155731f7e05036c7333e0 /synapse/logging/context.py | |
parent | Merge branch 'anoa/v2_lookup' of github.com:matrix-org/synapse into anoa/v2_l... (diff) | |
parent | Fix docstring (diff) | |
download | synapse-d9d156b5cdfe340a9b9c53b4002e5a14c5e9d68b.tar.xz |
Merge branch 'develop' into anoa/v2_lookup
Diffstat (limited to 'synapse/logging/context.py')
-rw-r--r-- | synapse/logging/context.py | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/synapse/logging/context.py b/synapse/logging/context.py index b456c31f70..63379bfb93 100644 --- a/synapse/logging/context.py +++ b/synapse/logging/context.py @@ -25,6 +25,7 @@ See doc/log_contexts.rst for details on how this works. import logging import threading import types +from typing import Any, List from twisted.internet import defer, threads @@ -194,7 +195,7 @@ class LoggingContext(object): class Sentinel(object): """Sentinel to represent the root context""" - __slots__ = [] + __slots__ = [] # type: List[Any] def __str__(self): return "sentinel" @@ -202,6 +203,10 @@ class LoggingContext(object): def copy_to(self, record): pass + def copy_to_twisted_log_entry(self, record): + record["request"] = None + record["scope"] = None + def start(self): pass @@ -330,6 +335,13 @@ class LoggingContext(object): # we also track the current scope: record.scope = self.scope + def copy_to_twisted_log_entry(self, record): + """ + Copy logging fields from this context to a Twisted log record. + """ + record["request"] = self.request + record["scope"] = self.scope + def start(self): if get_thread_id() != self.main_thread: logger.warning("Started logcontext %s on different thread", self) |