Skip to content

Commit db3d958

Browse files
committed
Use LOG_TRIM as the trimming window size
1 parent 9a13286 commit db3d958

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

aiopslab/orchestrator/actions/log_deduplication.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,14 +106,20 @@ def mask_timestamps(text: str, spans: list[tuple[int, int]]) -> str:
106106
def greedy_compress_lines(
107107
raw_str: str,
108108
ts_rx: re.Pattern[str] = DEFAULT_TS_RX,
109-
window_size: int = 2
110109
) -> str:
111110
"""
112111
Run greedy dedup with passes from block_size=1 up to block_size=window_size.
112+
window_size = LOG_TRIM if LOG_TRIM is int or trimming is disabled
113113
"""
114-
enabled = os.environ.get("LOG_TRIM")
115-
if not enabled:
114+
log_trim = None
115+
try:
116+
value = os.environ.get("LOG_TRIM")
117+
log_trim = int(value) if value is not None else None
118+
except ValueError:
119+
log_trim = None
120+
if not log_trim:
116121
return raw_str
122+
window_size = log_trim
117123
lines = raw_str.splitlines()
118124
result = lines[:]
119125
for size in range(1, window_size + 1):

0 commit comments

Comments
 (0)