Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix line number in workflow.logger #460

Merged
merged 1 commit into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions temporalio/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -1104,10 +1104,11 @@ def process(
kwargs["extra"] = extra
return (msg, kwargs)

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

@property
def base_logger(self) -> logging.Logger:
Expand Down
3 changes: 2 additions & 1 deletion tests/worker/test_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -1907,11 +1907,12 @@ def find_log(starts_with: str) -> Optional[logging.LogRecord]:
assert find_log("Signal: signal 1 ({'attempt':")
assert find_log("Signal: signal 2")
assert not find_log("Signal: signal 3")
# Also make sure it has some workflow info
# Also make sure it has some workflow info and correct funcName
record = find_log("Signal: signal 1")
assert (
record
and record.__dict__["workflow_info"].workflow_type == "LoggingWorkflow"
and record.funcName == "my_signal"
)

# Clear queue and start a new one with more signals
Expand Down
Loading