Bind *tmp_values* to *logger* & memorize current state. Rewind afterwards. Only works with `structlog.threadlocal.wrap_dict`-based contexts. Use :func:`~structlog.threadlocal.bound_threadlocal` for new code. .. deprecated:: 22.1.0
(
logger: TLLogger, **tmp_values: Any
)
| 137 | |
| 138 | @contextlib.contextmanager |
| 139 | def tmp_bind( |
| 140 | logger: TLLogger, **tmp_values: Any |
| 141 | ) -> Generator[TLLogger, None, None]: |
| 142 | """ |
| 143 | Bind *tmp_values* to *logger* & memorize current state. Rewind afterwards. |
| 144 | |
| 145 | Only works with `structlog.threadlocal.wrap_dict`-based contexts. |
| 146 | Use :func:`~structlog.threadlocal.bound_threadlocal` for new code. |
| 147 | |
| 148 | .. deprecated:: 22.1.0 |
| 149 | """ |
| 150 | _deprecated() |
| 151 | if isinstance(logger, BoundLoggerLazyProxy): |
| 152 | logger = logger.bind() |
| 153 | |
| 154 | saved = as_immutable(logger)._context |
| 155 | try: |
| 156 | yield logger.bind(**tmp_values) |
| 157 | finally: |
| 158 | logger._context.clear() |
| 159 | logger._context.update(saved) |
| 160 | |
| 161 | |
| 162 | class _ThreadLocalDictWrapper: |
searching dependent graphs…