Skip to content

Commit b43b980

Browse files
committed
Make LoggerAdapter behavior identical to merge_extra=True
1 parent 7c7516d commit b43b980

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

temporalio/workflow.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1211,6 +1211,10 @@ class LoggerAdapter(logging.LoggerAdapter):
12111211
use by others. Default is False.
12121212
log_during_replay: Boolean for whether logs should occur during replay.
12131213
Default is False.
1214+
1215+
Values added to ``extra`` are merged with the ``extra`` map from a logging
1216+
call, with values from the logging call taking precedence. I.e. the
1217+
behavior is that of `merge_extra=True` in Python >= 3.13.
12141218
"""
12151219

12161220
def __init__(
@@ -1232,20 +1236,17 @@ def process(
12321236
or self.workflow_info_on_extra
12331237
or self.full_workflow_info_on_extra
12341238
):
1239+
extra = {}
12351240
runtime = _Runtime.maybe_current()
12361241
if runtime:
12371242
if self.workflow_info_on_message:
12381243
msg = f"{msg} ({runtime.logger_details})"
12391244
if self.workflow_info_on_extra:
1240-
# Extra can be absent or None, this handles both
1241-
extra = kwargs.get("extra", None) or {}
12421245
extra["temporal_workflow"] = runtime.logger_details
1243-
kwargs["extra"] = extra
12441246
if self.full_workflow_info_on_extra:
1245-
# Extra can be absent or None, this handles both
1246-
extra = kwargs.get("extra", None) or {}
12471247
extra["workflow_info"] = runtime.workflow_info()
1248-
kwargs["extra"] = extra
1248+
1249+
kwargs["extra"] = {**extra, **(kwargs.get("extra") or {})}
12491250
return (msg, kwargs)
12501251

12511252
def isEnabledFor(self, level: int) -> bool:

0 commit comments

Comments
 (0)