API refactor
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2025-10-07 16:25:52 +09:00
parent 76d0d86211
commit 91c7e04474
1171 changed files with 81940 additions and 44117 deletions

View File

@@ -83,8 +83,7 @@ def wrap_dict(dict_class: type[Context]) -> type[Context]:
The wrapped class and used to keep global in the current thread.
Arguments:
Args:
dict_class: Class used for keeping context.
.. deprecated:: 22.1.0
@@ -106,20 +105,18 @@ def as_immutable(logger: TLLogger) -> TLLogger:
"""
Extract the context from a thread local logger into an immutable logger.
Arguments:
Args:
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() # type: ignore[assignment]
logger = logger.bind()
try:
ctx = logger._context._tl.dict_.__class__( # type: ignore[union-attr]
@@ -150,9 +147,12 @@ 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) # type: ignore[misc]
yield logger.bind(**tmp_values)
finally:
logger._context.clear()
logger._context.update(saved)