File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11"""
22Changes the log level of workflow task failures from WARN to ERROR.
3+
4+ Note that the __temporal_error_identifier attribute was added in
5+ version 1.13.0 of the Python SDK.
36"""
47
58import asyncio
1114from temporalio .worker import Worker
1215
1316# --- Begin logging set‑up ----------------------------------------------------------
14- _WORKFLOW_TASK_FAILURE_LOG_PREFIX = "Failed activation on workflow"
15-
1617logging .basicConfig (
1718 stream = sys .stdout ,
1819 level = logging .INFO ,
2223
2324class CustomLogFilter (logging .Filter ):
2425 def filter (self , record : logging .LogRecord ) -> bool :
26+ # Note that the __temporal_error_identifier attribute was added in
27+ # version 1.13.0 of the Python SDK.
2528 if (
26- record . msg . startswith ( _WORKFLOW_TASK_FAILURE_LOG_PREFIX )
27- and record . levelno < logging . ERROR
29+ hasattr ( record , "__temporal_error_identifier" )
30+ and getattr ( record , "__temporal_error_identifier" ) == "WorkflowTaskFailure"
2831 ):
2932 record .levelno = logging .ERROR
3033 record .levelname = logging .getLevelName (logging .ERROR )
You can’t perform that action at this time.
0 commit comments