This commit is contained in:
@@ -83,7 +83,8 @@ def wrap_dict(dict_class: type[Context]) -> type[Context]:
|
||||
|
||||
The wrapped class and used to keep global in the current thread.
|
||||
|
||||
Args:
|
||||
Arguments:
|
||||
|
||||
dict_class: Class used for keeping context.
|
||||
|
||||
.. deprecated:: 22.1.0
|
||||
@@ -105,18 +106,20 @@ def as_immutable(logger: TLLogger) -> TLLogger:
|
||||
"""
|
||||
Extract the context from a thread local logger into an immutable logger.
|
||||
|
||||
Args:
|
||||
Arguments:
|
||||
|
||||
logger (structlog.typing.BindableLogger):
|
||||
A logger with *possibly* thread local state.
|
||||
|
||||
Returns:
|
||||
|
||||
:class:`~structlog.BoundLogger` with an immutable context.
|
||||
|
||||
.. deprecated:: 22.1.0
|
||||
"""
|
||||
_deprecated()
|
||||
if isinstance(logger, BoundLoggerLazyProxy):
|
||||
logger = logger.bind()
|
||||
logger = logger.bind() # type: ignore[assignment]
|
||||
|
||||
try:
|
||||
ctx = logger._context._tl.dict_.__class__( # type: ignore[union-attr]
|
||||
@@ -147,12 +150,9 @@ def tmp_bind(
|
||||
.. deprecated:: 22.1.0
|
||||
"""
|
||||
_deprecated()
|
||||
if isinstance(logger, BoundLoggerLazyProxy):
|
||||
logger = logger.bind()
|
||||
|
||||
saved = as_immutable(logger)._context
|
||||
try:
|
||||
yield logger.bind(**tmp_values)
|
||||
yield logger.bind(**tmp_values) # type: ignore[misc]
|
||||
finally:
|
||||
logger._context.clear()
|
||||
logger._context.update(saved)
|
||||
|
||||
Reference in New Issue
Block a user