From 446defea2c322587317738033baa2f476c481dd8 Mon Sep 17 00:00:00 2001 From: nexy7574 Date: Wed, 1 May 2024 20:18:38 +0100 Subject: [PATCH] Improve uptime kuma logging --- src/main.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main.py b/src/main.py index ed0db78..2b692b3 100644 --- a/src/main.py +++ b/src/main.py @@ -50,10 +50,16 @@ class KumaThread(KillableThread): start_time = time.time() try: self.retries += 1 - response = client.get(self.url) + url = self.url + if url.endswith("ping="): + url += str(round(bot.latency, 2)) + if bot.is_ready() is False: + url = url.replace("status=up", "status=down") + url = url.replace("msg=OK", "msg=Bot%20not%20ready") + response = client.get(url) response.raise_for_status() except httpx.HTTPError as error: - self.log.error("Failed to connect to uptime-kuma: %r: %r", self.url, error, exc_info=error) + self.log.error("Failed to connect to uptime-kuma: %r: %r", url, error, exc_info=error) timeout = self.calculate_backoff() self.log.warning("Waiting %d seconds before retrying ping.", timeout) time.sleep(timeout) @@ -140,6 +146,7 @@ for module in CONFIG["jimmy"].get("modules", ["cogs/*.py"]): else: log.info(f"Loaded extension {module}") + @bot.event async def on_ready(): log.info(f"Logged in as {bot.user} ({bot.user.id})")