From 0c417a9acd6a25ce003d0e897a6d29f8a4e64dbd Mon Sep 17 00:00:00 2001 From: Sam Date: Sun, 31 Aug 2025 21:09:51 +0000 Subject: [PATCH] logging --- url_watcher.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/url_watcher.py b/url_watcher.py index f5240b9..a5f5e2b 100644 --- a/url_watcher.py +++ b/url_watcher.py @@ -88,10 +88,15 @@ def check_url(self, url): # Send SMS notification if configured if self.sms_notifier and self.sms_notifier.is_configured(): try: - self.sms_notifier.send_notification(url, diff) - logging.info(f"SMS notification sent for URL: {url}") + success = self.sms_notifier.send_notification(url, diff) + if success: + logging.info(f"SMS notification sent successfully for URL: {url}") + else: + logging.error( + f"SMS notification failed for URL: {url} - check logs for details" + ) except Exception as e: - logging.error(f"Failed to send SMS notification: {e}") + logging.error(f"Unexpected error sending SMS notification for URL {url}: {e}") # Update cache with new content self.cache[url] = { @@ -165,6 +170,13 @@ def watch_continuously(self, url, min_interval=60, max_interval=300): def main(): + # Configure logging to show SMS notification failures + logging.basicConfig( + level=logging.INFO, + format="%(asctime)s - %(levelname)s - %(message)s", + datefmt="%Y-%m-%d %H:%M:%S", + ) + if len(sys.argv) < 2: print("Usage: python url_watcher.py [--continuous] [--sms]") print(" Single check: python url_watcher.py ")