From 15099fade5ec9b52e48f952327f1e979b185e7fe Mon Sep 17 00:00:00 2001 From: Mark Haines Date: Tue, 25 Nov 2014 10:57:31 +0000 Subject: [PATCH] Drop log level for incorrect logging contexts to WARN if the context is wrong and DEBUG if the context is missing --- synapse/util/logcontext.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/synapse/util/logcontext.py b/synapse/util/logcontext.py index 23b3decb4..7d85018d9 100644 --- a/synapse/util/logcontext.py +++ b/synapse/util/logcontext.py @@ -55,11 +55,14 @@ class LoggingContext(object): None to avoid suppressing any exeptions that were thrown. """ if self.thread_local.current_context is not self: - logger.error( - "Current logging context %s is not the expected context %s", - self.thread_local.current_context, - self - ) + if self.thread_local.current_context is self.sentinel: + logger.debug("Expected logging context %s has been lost", self) + else: + logger.warn( + "Current logging context %s is not expected context %s", + self.thread_local.current_context, + self + ) self.thread_local.current_context = self.parent_context self.parent_context = None