From 59facea792dfde4be64edcb93ca0678c145b74bf Mon Sep 17 00:00:00 2001 From: Eric Eastwood Date: Tue, 2 Aug 2022 13:52:34 -0500 Subject: Restore logging current_context (not sure why removed --- synapse/logging/context.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'synapse/logging/context.py') diff --git a/synapse/logging/context.py b/synapse/logging/context.py index 6dd1fa525c..dde9c151f5 100644 --- a/synapse/logging/context.py +++ b/synapse/logging/context.py @@ -327,6 +327,22 @@ class LoggingContext: def __str__(self) -> str: return self.name + @classmethod + def current_context(cls) -> LoggingContextOrSentinel: + """Get the current logging context from thread local storage + This exists for backwards compatibility. ``current_context()`` should be + called directly. + Returns: + LoggingContext: the current logging context + """ + warnings.warn( + "synapse.logging.context.LoggingContext.current_context() is deprecated " + "in favor of synapse.logging.context.current_context().", + DeprecationWarning, + stacklevel=2, + ) + return current_context() + @classmethod def set_current_context( cls, context: LoggingContextOrSentinel -- cgit 1.5.1