From dfdda2c8718b11bff9eb69d382eff72c9f8a3d79 Mon Sep 17 00:00:00 2001 From: Mark Haines Date: Thu, 20 Nov 2014 17:10:37 +0000 Subject: Use module loggers rather than the root logger. Exceptions caused by bad clients shouldn't cause ERROR level logging. Fix sql logging to use 'repr' rather than 'str' --- synapse/util/logcontext.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'synapse/util/logcontext.py') diff --git a/synapse/util/logcontext.py b/synapse/util/logcontext.py index 2f430a0f19..23b3decb45 100644 --- a/synapse/util/logcontext.py +++ b/synapse/util/logcontext.py @@ -1,6 +1,8 @@ import threading import logging +logger = logging.getLogger(__name__) + class LoggingContext(object): """Additional context for log formatting. Contexts are scoped within a @@ -53,7 +55,7 @@ class LoggingContext(object): None to avoid suppressing any exeptions that were thrown. """ if self.thread_local.current_context is not self: - logging.error( + logger.error( "Current logging context %s is not the expected context %s", self.thread_local.current_context, self -- cgit 1.5.1 From 15099fade5ec9b52e48f952327f1e979b185e7fe Mon Sep 17 00:00:00 2001 From: Mark Haines Date: Tue, 25 Nov 2014 10:57:31 +0000 Subject: 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(-) (limited to 'synapse/util/logcontext.py') diff --git a/synapse/util/logcontext.py b/synapse/util/logcontext.py index 23b3decb45..7d85018d97 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 -- cgit 1.5.1