Skip to content

Commit 75e283d

Browse files
committed
Simplify as per @cretz suggestion
1 parent 51ddde6 commit 75e283d

File tree

2 files changed

+10
-14
lines changed

2 files changed

+10
-14
lines changed

temporalio/workflow.py

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import warnings
1212
from abc import ABC, abstractmethod
1313
from contextlib import contextmanager
14-
from dataclasses import asdict, dataclass
14+
from dataclasses import dataclass
1515
from datetime import datetime, timedelta, timezone
1616
from enum import Enum, IntEnum
1717
from functools import partial
@@ -1213,10 +1213,6 @@ class LoggerAdapter(logging.LoggerAdapter):
12131213
dictionary value will be added to the ``extra`` dictionary with some
12141214
workflow info, making it present on the ``LogRecord.__dict__`` for
12151215
use by others. Default is True.
1216-
update_info_on_extra: Boolean for whether a ``temporal_update``
1217-
dictionary value will be added to the ``extra`` dictionary with some
1218-
update info, making it present on the ``LogRecord.__dict__`` for use
1219-
by others. Default is True.
12201216
full_workflow_info_on_extra: Boolean for whether a ``workflow_info``
12211217
value will be added to the ``extra`` dictionary with the entire
12221218
workflow info, making it present on the ``LogRecord.__dict__`` for
@@ -1236,7 +1232,6 @@ def __init__(
12361232
super().__init__(logger, extra or {})
12371233
self.workflow_info_on_message = True
12381234
self.workflow_info_on_extra = True
1239-
self.update_info_on_extra = True
12401235
self.full_workflow_info_on_extra = False
12411236
self.log_during_replay = False
12421237

@@ -1247,25 +1242,26 @@ def process(
12471242
if (
12481243
self.workflow_info_on_message
12491244
or self.workflow_info_on_extra
1250-
or self.update_info_on_extra
12511245
or self.full_workflow_info_on_extra
12521246
):
12531247
extra: Dict[str, Any] = {}
12541248
msg_extra: Dict[str, Any] = {}
12551249
runtime = _Runtime.maybe_current()
12561250
if runtime:
1251+
workflow_details = runtime.logger_details
12571252
if self.workflow_info_on_message:
1258-
msg_extra.update(runtime.logger_details)
1253+
msg_extra.update(workflow_details)
12591254
if self.workflow_info_on_extra:
1260-
extra["temporal_workflow"] = runtime.logger_details
1255+
extra["temporal_workflow"] = workflow_details
12611256
if self.full_workflow_info_on_extra:
12621257
extra["workflow_info"] = runtime.workflow_info()
12631258
update_info = current_update_info()
12641259
if update_info:
1265-
if self.update_info_on_extra:
1266-
extra["temporal_update"] = asdict(update_info)
1260+
update_details = update_info.logger_details
12671261
if self.workflow_info_on_message:
1268-
msg_extra.update(update_info.logger_details)
1262+
msg_extra.update(update_details)
1263+
if self.workflow_info_on_extra:
1264+
extra.setdefault("temporal_workflow", {}).update(update_details)
12691265

12701266
kwargs["extra"] = {**extra, **(kwargs.get("extra") or {})}
12711267
if msg_extra:

tests/worker/test_workflow.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1990,8 +1990,8 @@ async def test_workflow_logging(client: Client, env: WorkflowEnvironment):
19901990
record = capturer.find_log("Update: update 1")
19911991
assert (
19921992
record
1993-
and record.__dict__["temporal_update"]["id"] == "update-1"
1994-
and record.__dict__["temporal_update"]["name"] == "my_update"
1993+
and record.__dict__["temporal_workflow"]["update_id"] == "update-1"
1994+
and record.__dict__["temporal_workflow"]["update_name"] == "my_update"
19951995
and "'update_id': 'update-1'" in record.message
19961996
and "'update_name': 'my_update'" in record.message
19971997
)

0 commit comments

Comments
 (0)