Skip to content

Commit e3630ef

Browse files
authored
Fix line number in workflow.logger (#460)
1 parent 4037dd4 commit e3630ef

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

temporalio/workflow.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1104,10 +1104,11 @@ def process(
11041104
kwargs["extra"] = extra
11051105
return (msg, kwargs)
11061106

1107-
def log(self, *args, **kwargs) -> None:
1107+
def isEnabledFor(self, level: int) -> bool:
11081108
"""Override to ignore replay logs."""
1109-
if self.log_during_replay or not unsafe.is_replaying():
1110-
super().log(*args, **kwargs)
1109+
if not self.log_during_replay and unsafe.is_replaying():
1110+
return False
1111+
return super().isEnabledFor(level)
11111112

11121113
@property
11131114
def base_logger(self) -> logging.Logger:

tests/worker/test_workflow.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1907,11 +1907,12 @@ def find_log(starts_with: str) -> Optional[logging.LogRecord]:
19071907
assert find_log("Signal: signal 1 ({'attempt':")
19081908
assert find_log("Signal: signal 2")
19091909
assert not find_log("Signal: signal 3")
1910-
# Also make sure it has some workflow info
1910+
# Also make sure it has some workflow info and correct funcName
19111911
record = find_log("Signal: signal 1")
19121912
assert (
19131913
record
19141914
and record.__dict__["workflow_info"].workflow_type == "LoggingWorkflow"
1915+
and record.funcName == "my_signal"
19151916
)
19161917

19171918
# Clear queue and start a new one with more signals

0 commit comments

Comments
 (0)