Skip to content
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: 7 additions & 0 deletions tests/test_run/test_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ def test_path_contains_run_title(self):
result = configure_logger_for_run("special_run_title")
assert "special_run_title" in result

def test_log_file_sink_is_not_enqueued(self):
with patch("th_cli.test_run.logging.logger") as mock_logger:
result = configure_logger_for_run("run")
mock_logger.add.assert_called_once()
assert mock_logger.add.call_args.args[0] == result
assert mock_logger.add.call_args.kwargs["enqueue"] is False

def test_log_handler_remains_none_when_streaming_disabled(self):
with patch("th_cli.test_run.logging.logger"):
configure_logger_for_run("run", enable_log_streaming=False)
Expand Down
7 changes: 6 additions & 1 deletion th_cli/test_run/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,12 @@ def configure_logger_for_run(title: str, enable_log_streaming: bool = False) ->
f"test_run_{title}_{timestamp}.log",
)

logger.add(log_path, enqueue=True, format=config.log_config.format, mode="w")
# enqueue=False: write the file synchronously. With enqueue=True every
# line is pickled onto a multiprocessing queue and handed to a worker
# thread, which costs ~3x more per line than the write itself and is what
# limits how fast the CLI can drain a large run's log records. Loguru
# still serialises concurrent writers with a per-handler lock.
logger.add(log_path, enqueue=False, format=config.log_config.format, mode="w")

# Add streaming sink if enabled
if enable_log_streaming:
Expand Down
Loading