diff --git a/app.py b/app.py index bae821f..5011caa 100644 --- a/app.py +++ b/app.py @@ -3,7 +3,8 @@ import json import requests import tzdata import sys - + +from loguru import logger from datetime import datetime, timedelta from zoneinfo import ZoneInfo from urllib.parse import urlparse @@ -53,7 +54,7 @@ def create_calendar_events_from_json(caldav_url, calendar_name, username, passwo #print(f"Remaining duplicates: {len(remaining)}") # 4. Create events from JSON data - print(f"Updating calendar...") + logger.info("Updating calendar...") ical_data_event = f"""BEGIN:VCALENDAR VERSION:2.0 BEGIN:VEVENT @@ -66,7 +67,7 @@ CATEGORIES:RetroAchievements END:VEVENT END:VCALENDAR """ - print(f"Updating reminders...") + logger.info("Updating todos...") ical_data_todo = f"""BEGIN:VCALENDAR VERSION:2.0 BEGIN:VTODO @@ -82,19 +83,20 @@ END:VCALENDAR """ my_calendar.save_event(ical_data_event) - print(f"Calendar was updated.") + logger.info("Calendar updated.") my_calendar.save_todo(ical_data_todo) - print(f"Reminders were updated.") + logger.info("Calendar updated.") except Exception as e: - print(f"Error: {str(e)}") + logger.exception{"Error: {str(e)}"} # Usage example if __name__ == "__main__": + logger.add("output.log", backtrace=True, diagnose=True) if len(sys.argv) != 7: - print("Usage: python3 app.py [OPTIONAL] ") + logger.exception{"Usage: python3 app.py [OPTIONAL] "} sys.exit(1) CALDAV_URL = sys.argv[1]