@@ -263,7 +263,7 @@ def parse_rules_from_log(log_path: Path) -> dict[str, int]:
263263 try :
264264 for line in log_path .read_text ().splitlines ():
265265 # Track current rule being executed
266- if match := RULE_START_PATTERN .match (line ):
266+ if match := RULE_START_PATTERN .match (line . lstrip () ):
267267 current_rule = match .group (1 )
268268 # Count "Finished job" as rule completion
269269 elif "Finished job" in line and current_rule is not None :
@@ -320,7 +320,7 @@ def record_pending_error() -> None:
320320 lines = _cached_lines if _cached_lines is not None else log_path .read_text ().splitlines ()
321321 for line_num , line in enumerate (lines ):
322322 # Track current rule being executed
323- if match := RULE_START_PATTERN .match (line ):
323+ if match := RULE_START_PATTERN .match (line . lstrip () ):
324324 record_pending_error ()
325325 current_rule = match .group (1 )
326326 current_jobid = None # Reset jobid for new rule block
@@ -329,7 +329,7 @@ def record_pending_error() -> None:
329329 current_log_path = None
330330
331331 # Timestamp lines end error blocks
332- elif line . startswith ( "[" ) and TIMESTAMP_PATTERN .match (line ):
332+ elif TIMESTAMP_PATTERN .search (line ):
333333 record_pending_error ()
334334
335335 # Capture wildcards within rule block
@@ -484,7 +484,7 @@ def emit_pending_error() -> None:
484484 lines = _cached_lines if _cached_lines is not None else log_path .read_text ().splitlines ()
485485 for line in lines :
486486 # Track current rule - this also ends any pending error block
487- if match := RULE_START_PATTERN .match (line ):
487+ if match := RULE_START_PATTERN .match (line . lstrip () ):
488488 emit_pending_error ()
489489 current_rule = match .group (1 )
490490 current_jobid = None
@@ -493,7 +493,7 @@ def emit_pending_error() -> None:
493493 current_log_path = None
494494
495495 # Timestamp lines end error blocks
496- elif line . startswith ( "[" ) and TIMESTAMP_PATTERN .match (line ):
496+ elif TIMESTAMP_PATTERN .search (line ):
497497 emit_pending_error ()
498498
499499 # Capture wildcards - applies to both rule blocks and error blocks
@@ -633,12 +633,12 @@ def _get_first_log_timestamp(
633633 try :
634634 if _cached_lines is not None :
635635 for line in _cached_lines :
636- if match := TIMESTAMP_PATTERN .match (line ):
636+ if match := TIMESTAMP_PATTERN .search (line ):
637637 return _parse_timestamp (match .group (1 ))
638638 else :
639639 with log_path .open () as f :
640640 for line in f :
641- if match := TIMESTAMP_PATTERN .match (line ):
641+ if match := TIMESTAMP_PATTERN .search (line ):
642642 return _parse_timestamp (match .group (1 ))
643643 except OSError as e :
644644 logger .info ("Could not read log file %s: %s" , log_path , e )
@@ -681,11 +681,11 @@ def parse_completed_jobs_from_log(
681681 lines = _cached_lines if _cached_lines is not None else log_path .read_text ().splitlines ()
682682 for line in lines :
683683 # Check for timestamp
684- if match := TIMESTAMP_PATTERN .match (line ):
684+ if match := TIMESTAMP_PATTERN .search (line ):
685685 current_timestamp = _parse_timestamp (match .group (1 ))
686686
687687 # Track current rule being executed
688- elif match := RULE_START_PATTERN .match (line ):
688+ elif match := RULE_START_PATTERN .match (line . lstrip () ):
689689 current_rule = match .group (1 )
690690 current_wildcards = None
691691 current_threads = None
@@ -769,7 +769,7 @@ def parse_threads_from_log(log_path: Path) -> dict[str, int]:
769769 try :
770770 for line in log_path .read_text ().splitlines ():
771771 # Track current rule (resets context)
772- if RULE_START_PATTERN .match (line ):
772+ if RULE_START_PATTERN .match (line . lstrip () ):
773773 current_jobid = None
774774 current_threads = None
775775
@@ -826,7 +826,7 @@ def parse_all_jobs_from_log(
826826 lines = _cached_lines if _cached_lines is not None else log_path .read_text ().splitlines ()
827827 for line in lines :
828828 # Track current rule being scheduled
829- if match := RULE_START_PATTERN .match (line ):
829+ if match := RULE_START_PATTERN .match (line . lstrip () ):
830830 # Save previous job if complete
831831 if current_rule is not None and current_jobid is not None :
832832 if current_jobid not in seen_jobids :
0 commit comments