summary refs log tree commit diff
path: root/synapse/logging/context.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2019-08-29 11:18:57 +0100
committerErik Johnston <erik@matrix.org>2019-08-29 11:18:57 +0100
commita81e0233e917178750c45c067476332407f5658c (patch)
treee5d2f134baa7f420fde71afc484d2c62b71df33c /synapse/logging/context.py
parentMerge branch 'release-v1.3.1' into matrix-org-hotfixes (diff)
parentAdd a link to python's logging config schema (#5926) (diff)
downloadsynapse-a81e0233e917178750c45c067476332407f5658c.tar.xz
Merge branch 'develop' of github.com:matrix-org/synapse into matrix-org-hotfixes
Diffstat (limited to 'synapse/logging/context.py')
-rw-r--r--synapse/logging/context.py14
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)