Refactor check_logs function in checker.py to simplify log handling. Removed subscription message detection logic and replaced it with a basic line printing mechanism. The function now returns a default status of "Idle", streamlining the process and reducing complexity in log analysis.

This commit is contained in:
vvzvlad 2025-01-19 11:37:27 +03:00
parent 246e073092
commit a5a27829de

View File

@ -138,24 +138,11 @@ def check_logs(log_handler):
except subprocess.CalledProcessError as e: except subprocess.CalledProcessError as e:
raise RuntimeError(f"Error running docker logs: {e}") raise RuntimeError(f"Error running docker logs: {e}")
subscription_pattern = r'\[info\s*\].*Ignored subscription creation.*id=(\d+).*err=(.+?)(?=\s+\[|$)' for line in log_content.splitlines():
matches = list(re.finditer(subscription_pattern, log_content)) print(line)
if not matches: return {"status": "Idle"}
log_handler.info("No subscription messages found")
return {"status": "Idle"}
last_match = matches[-1]
last_id = last_match.group(1)
error_type = last_match.group(2).strip()
if error_type == "Container-set not supported":
status = f"Container error (id: {last_id})"
else:
status = f"Subscription {last_id}"
log_handler.info(f"Found subscription message: id={last_id}, error={error_type}")
return {"status": status}
if __name__ == "__main__": if __name__ == "__main__":
colorama.init(autoreset=True) colorama.init(autoreset=True)