Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/18989.removal
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove deprecated `LoggingContext.set_current_context`/`LoggingContext.current_context` methods which already have equivalent bare methods in `synapse.logging.context`.
Comment thread
MadLittleMods marked this conversation as resolved.
41 changes: 0 additions & 41 deletions synapse/logging/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import logging
import threading
import typing
import warnings

Check failure on line 36 in synapse/logging/context.py

View workflow job for this annotation

GitHub Actions / lint

Ruff (F401)

synapse/logging/context.py:36:8: F401 `warnings` imported but unused
from types import TracebackType
from typing import (
TYPE_CHECKING,
Expand Down Expand Up @@ -347,47 +347,6 @@
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:
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":
"""Enters this logging context into thread local storage"""
old_context = set_current_context(self)
Expand Down
Loading