diff --git a/resource_processor/_version.py b/resource_processor/_version.py index 8762258101..d69d16e980 100644 --- a/resource_processor/_version.py +++ b/resource_processor/_version.py @@ -1 +1 @@ -__version__ = "0.9.1" +__version__ = "0.9.1" diff --git a/resource_processor/shared/logging.py b/resource_processor/shared/logging.py index a2d2c1a3a0..ca294d2ac0 100644 --- a/resource_processor/shared/logging.py +++ b/resource_processor/shared/logging.py @@ -97,10 +97,13 @@ def initialize_logging() -> logging.Logger: def chunk_log_output(output: str, chunk_size: int = 30000): """ - Split the log output into smaller chunks. + Split the log output into smaller chunks and prefix each chunk with [Log chunk X of Y]. """ + total_chunks = (len(output) + chunk_size - 1) // chunk_size # Calculate total number of chunks for i in range(0, len(output), chunk_size): - yield output[i:i + chunk_size] + current_chunk = i // chunk_size + 1 + prefix = f"[Log chunk {current_chunk} of {total_chunks}] " + yield prefix + output[i:i + chunk_size] def shell_output_logger(console_output: str, prefix_item: str, logging_level: int): diff --git a/resource_processor/tests_rp/test_logging.py b/resource_processor/tests_rp/test_logging.py index d1147d0627..52c4c53c5c 100644 --- a/resource_processor/tests_rp/test_logging.py +++ b/resource_processor/tests_rp/test_logging.py @@ -36,13 +36,13 @@ def test_shell_output_logger_chunked_logging(mock_logger): console_output = "A" * 60000 # 60,000 characters long shell_output_logger(console_output, "prefix", logging.DEBUG) assert mock_logger.log.call_count == 2 - mock_logger.log.assert_any_call(logging.DEBUG, f"prefix {'A' * 30000}") - mock_logger.log.assert_any_call(logging.DEBUG, f"prefix {'A' * 30000}") + mock_logger.log.assert_any_call(logging.DEBUG, f"prefix [Log chunk 1 of 2] {'A' * 30000}") + mock_logger.log.assert_any_call(logging.DEBUG, f"prefix [Log chunk 2 of 2] {'A' * 30000}") def test_chunk_log_output(): output = "A" * 60000 # 60,000 characters long chunks = list(chunk_log_output(output, chunk_size=30000)) assert len(chunks) == 2 - assert chunks[0] == "A" * 30000 - assert chunks[1] == "A" * 30000 + assert chunks[0] == "[Log chunk 1 of 2] " + "A" * 30000 + assert chunks[1] == "[Log chunk 2 of 2] " + "A" * 30000