66from __future__ import annotations
77
88from dataclasses import dataclass
9- from typing import Any , Mapping , Optional , Sequence , Type
9+ from typing import Any , Callable , Dict , Mapping , Optional , Sequence , Type
10+
11+ from typing_extensions import Protocol
1012
1113import temporalio .bridge .temporal_sdk_bridge
1214
@@ -29,13 +31,21 @@ def retrieve_buffered_metrics(self) -> Sequence[Any]:
2931 """Get buffered metrics."""
3032 return self ._ref .retrieve_buffered_metrics ()
3133
34+ def write_test_info_log (self , message : str , extra_data : str ) -> None :
35+ """Write a test core log at INFO level."""
36+ self ._ref .write_test_info_log (message , extra_data )
37+
38+ def write_test_debug_log (self , message : str , extra_data : str ) -> None :
39+ """Write a test core log at DEBUG level."""
40+ self ._ref .write_test_debug_log (message , extra_data )
41+
3242
3343@dataclass (frozen = True )
3444class LoggingConfig :
3545 """Python representation of the Rust struct for logging config."""
3646
3747 filter : str
38- forward : bool
48+ forward_to : Optional [ Callable [[ Sequence [ BufferedLogEntry ]], None ]]
3949
4050
4151@dataclass (frozen = True )
@@ -75,3 +85,42 @@ class TelemetryConfig:
7585
7686 logging : Optional [LoggingConfig ]
7787 metrics : Optional [MetricsConfig ]
88+
89+
90+ # WARNING: This must match Rust runtime::BufferedLogEntry
91+ class BufferedLogEntry (Protocol ):
92+ """A buffered log entry."""
93+
94+ @property
95+ def target (self ) -> str :
96+ """Target category for the log entry."""
97+ ...
98+
99+ @property
100+ def message (self ) -> str :
101+ """Log message."""
102+ ...
103+
104+ @property
105+ def time (self ) -> float :
106+ """Time as from ``time.time`` since Unix epoch."""
107+ ...
108+
109+ @property
110+ def level (self ) -> int :
111+ """Python log level, with trace as 9."""
112+ ...
113+
114+ @property
115+ def fields (self ) -> Dict [str , Any ]:
116+ """Additional log entry fields.
117+ Requesting this property performs a conversion from the internal
118+ representation to the Python representation on every request. Therefore
119+ callers should store the result instead of repeatedly calling.
120+
121+ Raises:
122+ Exception: If the internal representation cannot be converted. This
123+ should not happen and if it does it is considered a bug in the
124+ SDK and should be reported.
125+ """
126+ ...
0 commit comments