mirror of
https://github.com/element-hq/synapse.git
synced 2025-11-29 00:00:50 -05:00
Remove deprecated LoggingContext.set_current_context/LoggingContext.current_context methods (#18989)
These were added for backwards compatibility (and essentially deprecated) in https://github.com/matrix-org/synapse/pull/7408 (2020-05-04) because [`synapse-s3-storage-provider`](https://github.com/matrix-org/synapse-s3-storage-provider) previously relied on them -- but `synapse-s3-storage-provider` since been [updated](https://github.com/matrix-org/synapse-s3-storage-provider/pull/36) to no longer use them.
This commit is contained in:
parent
6835e7be0d
commit
70c044db8e
1
changelog.d/18989.removal
Normal file
1
changelog.d/18989.removal
Normal file
@ -0,0 +1 @@
|
|||||||
|
Remove deprecated `LoggingContext.set_current_context`/`LoggingContext.current_context` methods which already have equivalent bare methods in `synapse.logging.context`.
|
||||||
@ -33,7 +33,6 @@ See doc/log_contexts.rst for details on how this works.
|
|||||||
import logging
|
import logging
|
||||||
import threading
|
import threading
|
||||||
import typing
|
import typing
|
||||||
import warnings
|
|
||||||
from types import TracebackType
|
from types import TracebackType
|
||||||
from typing import (
|
from typing import (
|
||||||
TYPE_CHECKING,
|
TYPE_CHECKING,
|
||||||
@ -378,47 +377,6 @@ class LoggingContext:
|
|||||||
def __str__(self) -> str:
|
def __str__(self) -> str:
|
||||||
return self.name
|
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:
|
|
||||||
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
|
|
||||||
) -> LoggingContextOrSentinel:
|
|
||||||
"""Set the current logging context in thread local storage
|
|
||||||
|
|
||||||
This exists for backwards compatibility. ``set_current_context()`` should be
|
|
||||||
called directly.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
context: The context to activate.
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
The context that was previously active
|
|
||||||
"""
|
|
||||||
warnings.warn(
|
|
||||||
"synapse.logging.context.LoggingContext.set_current_context() is deprecated "
|
|
||||||
"in favor of synapse.logging.context.set_current_context().",
|
|
||||||
DeprecationWarning,
|
|
||||||
stacklevel=2,
|
|
||||||
)
|
|
||||||
return set_current_context(context)
|
|
||||||
|
|
||||||
def __enter__(self) -> "LoggingContext":
|
def __enter__(self) -> "LoggingContext":
|
||||||
"""Enters this logging context into thread local storage"""
|
"""Enters this logging context into thread local storage"""
|
||||||
logcontext_debug_logger.debug("LoggingContext(%s).__enter__", self.name)
|
logcontext_debug_logger.debug("LoggingContext(%s).__enter__", self.name)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user