From c88e1685a1e1cd215935d915644bc8815d0e782b Mon Sep 17 00:00:00 2001 From: Ryan Chen Date: Fri, 26 Sep 2025 10:46:47 -0400 Subject: [PATCH] logging --- main.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index f096e80..13344f8 100644 --- a/main.py +++ b/main.py @@ -1,8 +1,12 @@ from flask import Flask, request import httpx +import logging app = Flask(__name__) +# Configure logging +logging.basicConfig(level=logging.INFO) + def populate_webhook_lookup(): lookup = {} @@ -53,8 +57,16 @@ def convert(uuid): ghost_payload = request.get_json() discord_payload = convert_ghost_to_discord(ghost_payload) - r = httpx.post(webhook, json=discord_payload) - print(r) + try: + r = httpx.post(webhook, json=discord_payload) + if r.status_code == 200: + logging.info(f"Successfully posted to Discord webhook for UUID {uuid}") + else: + logging.warning(f"Discord webhook POST failed for UUID {uuid} with status {r.status_code}: {r.text}") + print(r) + except Exception as e: + logging.error(f"Failed to post to Discord webhook for UUID {uuid}: {str(e)}") + return "error", 500 return "yay"