Skip to content

Commit b1bc492

Browse files
committed
responded to PR comments
1 parent 168d7e0 commit b1bc492

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

hello/hello_change_log_level.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
"""
22
Changes 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

58
import asyncio
@@ -11,8 +14,6 @@
1114
from temporalio.worker import Worker
1215

1316
# --- Begin logging set‑up ----------------------------------------------------------
14-
_WORKFLOW_TASK_FAILURE_LOG_PREFIX = "Failed activation on workflow"
15-
1617
logging.basicConfig(
1718
stream=sys.stdout,
1819
level=logging.INFO,
@@ -22,9 +23,11 @@
2223

2324
class 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)

0 commit comments

Comments
 (0)