MCPcopy Create free account
hub / github.com/hynek/structlog / merge_threadlocal

Function merge_threadlocal

src/structlog/threadlocal.py:257–278  ·  view source on GitHub ↗

A processor that merges in a global (thread-local) context. Use this as your first processor in :func:`structlog.configure` to ensure thread-local context is included in all log calls. .. versionadded:: 19.2.0 .. versionchanged:: 20.1.0 This function used to be called

(
    logger: WrappedLogger, method_name: str, event_dict: EventDict
)

Source from the content-addressed store, hash-verified

255
256
257def merge_threadlocal(
258 logger: WrappedLogger, method_name: str, event_dict: EventDict
259) -> EventDict:
260 """
261 A processor that merges in a global (thread-local) context.
262
263 Use this as your first processor in :func:`structlog.configure` to ensure
264 thread-local context is included in all log calls.
265
266 .. versionadded:: 19.2.0
267
268 .. versionchanged:: 20.1.0
269 This function used to be called ``merge_threadlocal_context`` and that
270 name is still kept around for backward compatibility.
271
272 .. deprecated:: 22.1.0
273 """
274 _deprecated()
275 context = _get_context().copy()
276 context.update(event_dict)
277
278 return context
279
280
281# Alias that shouldn't be used anymore.

Callers 4

test_bind_and_mergeMethod · 0.90
test_clearMethod · 0.90
test_multiple_bindsMethod · 0.90

Calls 3

_deprecatedFunction · 0.85
_get_contextFunction · 0.85
updateMethod · 0.80

Tested by 4

test_bind_and_mergeMethod · 0.72
test_clearMethod · 0.72
test_multiple_bindsMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…