Skip to content

Commit 70c044d

Browse files
Remove deprecated LoggingContext.set_current_context/LoggingContext.current_context methods (#18989)
These were added for backwards compatibility (and essentially deprecated) in matrix-org/synapse#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](matrix-org/synapse-s3-storage-provider#36) to no longer use them.
1 parent 6835e7b commit 70c044d

File tree

2 files changed

+1
-42
lines changed

2 files changed

+1
-42
lines changed

changelog.d/18989.removal

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Remove deprecated `LoggingContext.set_current_context`/`LoggingContext.current_context` methods which already have equivalent bare methods in `synapse.logging.context`.

synapse/logging/context.py

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
import logging
3434
import threading
3535
import typing
36-
import warnings
3736
from types import TracebackType
3837
from typing import (
3938
TYPE_CHECKING,
@@ -378,47 +377,6 @@ def __init__(
378377
def __str__(self) -> str:
379378
return self.name
380379

381-
@classmethod
382-
def current_context(cls) -> LoggingContextOrSentinel:
383-
"""Get the current logging context from thread local storage
384-
385-
This exists for backwards compatibility. ``current_context()`` should be
386-
called directly.
387-
388-
Returns:
389-
The current logging context
390-
"""
391-
warnings.warn(
392-
"synapse.logging.context.LoggingContext.current_context() is deprecated "
393-
"in favor of synapse.logging.context.current_context().",
394-
DeprecationWarning,
395-
stacklevel=2,
396-
)
397-
return current_context()
398-
399-
@classmethod
400-
def set_current_context(
401-
cls, context: LoggingContextOrSentinel
402-
) -> LoggingContextOrSentinel:
403-
"""Set the current logging context in thread local storage
404-
405-
This exists for backwards compatibility. ``set_current_context()`` should be
406-
called directly.
407-
408-
Args:
409-
context: The context to activate.
410-
411-
Returns:
412-
The context that was previously active
413-
"""
414-
warnings.warn(
415-
"synapse.logging.context.LoggingContext.set_current_context() is deprecated "
416-
"in favor of synapse.logging.context.set_current_context().",
417-
DeprecationWarning,
418-
stacklevel=2,
419-
)
420-
return set_current_context(context)
421-
422380
def __enter__(self) -> "LoggingContext":
423381
"""Enters this logging context into thread local storage"""
424382
logcontext_debug_logger.debug("LoggingContext(%s).__enter__", self.name)

0 commit comments

Comments
 (0)