From c1f23386b5937a75e92247609651aa6899717fea Mon Sep 17 00:00:00 2001 From: vvzvlad Date: Sun, 19 Jan 2025 11:42:55 +0300 Subject: [PATCH] Refactor check_logs function in checker.py to improve logging and subscription status reporting. Renamed parameter from log_handler to logger for clarity. Added logging for cases where no subscription is found, enhancing the visibility of log analysis outcomes. --- checker.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/checker.py b/checker.py index b7408d7..9de8376 100644 --- a/checker.py +++ b/checker.py @@ -134,7 +134,7 @@ def clean_ansi(text): ansi_escape = re.compile(r'\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])') return ansi_escape.sub('', text) -def check_logs(log_handler): +def check_logs(logger): try: logs = subprocess.run(['docker', 'logs', '--since', '10m', 'infernet-node'], capture_output=True, text=True, check=True) log_content = clean_ansi(logs.stdout) @@ -147,7 +147,9 @@ def check_logs(log_handler): last_subscription_id = id_match.group(1) if last_subscription_id: + logger.info(f"Subscription: {last_subscription_id}") return {"status": f"Subscription: {last_subscription_id}"} + logger.info("Not found subscription") return {"status": "Idle"} except subprocess.CalledProcessError as e: