1111import warnings
1212from abc import ABC , abstractmethod
1313from contextlib import contextmanager
14- from dataclasses import dataclass
14+ from dataclasses import asdict , dataclass
1515from datetime import datetime , timedelta , timezone
1616from enum import Enum , IntEnum
1717from functools import partial
@@ -500,6 +500,14 @@ class UpdateInfo:
500500 name : str
501501 """Update type name."""
502502
503+ @property
504+ def logger_details (self ) -> Mapping [str , Any ]:
505+ """Data to be included in string appended to default logging output."""
506+ return {
507+ "update_id" : self .id ,
508+ "update_name" : self .name ,
509+ }
510+
503511
504512class _Runtime (ABC ):
505513 @staticmethod
@@ -1205,6 +1213,10 @@ class LoggerAdapter(logging.LoggerAdapter):
12051213 dictionary value will be added to the ``extra`` dictionary with some
12061214 workflow info, making it present on the ``LogRecord.__dict__`` for
12071215 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.
12081220 full_workflow_info_on_extra: Boolean for whether a ``workflow_info``
12091221 value will be added to the ``extra`` dictionary with the entire
12101222 workflow info, making it present on the ``LogRecord.__dict__`` for
@@ -1224,6 +1236,7 @@ def __init__(
12241236 super ().__init__ (logger , extra or {})
12251237 self .workflow_info_on_message = True
12261238 self .workflow_info_on_extra = True
1239+ self .update_info_on_extra = True
12271240 self .full_workflow_info_on_extra = False
12281241 self .log_during_replay = False
12291242
@@ -1234,10 +1247,11 @@ def process(
12341247 if (
12351248 self .workflow_info_on_message
12361249 or self .workflow_info_on_extra
1250+ or self .update_info_on_extra
12371251 or self .full_workflow_info_on_extra
12381252 ):
1239- extra = {}
1240- msg_extra = {}
1253+ extra : Dict [ str , Any ] = {}
1254+ msg_extra : Dict [ str , Any ] = {}
12411255 runtime = _Runtime .maybe_current ()
12421256 if runtime :
12431257 if self .workflow_info_on_message :
@@ -1246,6 +1260,12 @@ def process(
12461260 extra ["temporal_workflow" ] = runtime .logger_details
12471261 if self .full_workflow_info_on_extra :
12481262 extra ["workflow_info" ] = runtime .workflow_info ()
1263+ update_info = current_update_info ()
1264+ if update_info :
1265+ if self .update_info_on_extra :
1266+ extra ["temporal_update" ] = asdict (update_info )
1267+ if self .workflow_info_on_message :
1268+ msg_extra .update (update_info .logger_details )
12491269
12501270 kwargs ["extra" ] = {** extra , ** (kwargs .get ("extra" ) or {})}
12511271 if msg_extra :
0 commit comments