Skip to content

Commit bfc22ca

Browse files
committed
responded to PR comments
1 parent 65c60c2 commit bfc22ca

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

hello/hello_change_log_level.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
from temporalio.worker import Worker
1212

1313
# --- Begin logging set‑up ----------------------------------------------------------
14+
_WORKFLOW_TASK_FAILURE_LOG_PREFIX = "Failed activation on workflow"
15+
1416
logging.basicConfig(
1517
stream=sys.stdout,
1618
level=logging.INFO,
@@ -21,15 +23,16 @@
2123
class CustomLogFilter(logging.Filter):
2224
def filter(self, record: logging.LogRecord) -> bool:
2325
if (
24-
record.msg.startswith("Failed activation on workflow")
26+
record.msg.startswith(_WORKFLOW_TASK_FAILURE_LOG_PREFIX)
2527
and record.levelno < logging.ERROR
2628
):
2729
record.levelno = logging.ERROR
2830
record.levelname = logging.getLevelName(logging.ERROR)
2931
return True
3032

3133

32-
logging.getLogger("temporalio.worker._workflow_instance").addFilter(CustomLogFilter())
34+
for h in logging.getLogger().handlers:
35+
h.addFilter(CustomLogFilter())
3336
# --- End logging set‑up ----------------------------------------------------------
3437

3538

tests/hello/hello_change_log_level_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ async def test_workflow_with_log_capture(client: Client):
3333
)
3434
await asyncio.sleep(
3535
0.2
36-
) # arbitrary wait to ensure the workflow has started and logged
36+
) # small wait to ensure the workflow has started, failed, and logged
3737
await handle.terminate()
3838

3939
logger.removeHandler(handler)

0 commit comments

Comments
 (0)