mirror of
https://github.com/Monadical-SAS/reflector.git
synced 2025-12-21 20:59:05 +00:00
refactor: replace loguru with structlog in ics_sync service
- Replace loguru import with structlog in services/ics_sync.py
- Update logging calls to use structlog's structured format with keyword args
- Maintains consistency with other services using structlog
- Changes: logger.info(f'...') -> logger.info('...', key=value) format
This commit is contained in:
@@ -5,13 +5,15 @@ from typing import TypedDict
|
|||||||
|
|
||||||
import httpx
|
import httpx
|
||||||
import pytz
|
import pytz
|
||||||
|
import structlog
|
||||||
from icalendar import Calendar, Event
|
from icalendar import Calendar, Event
|
||||||
from loguru import logger
|
|
||||||
|
|
||||||
from reflector.db.calendar_events import CalendarEvent, calendar_events_controller
|
from reflector.db.calendar_events import CalendarEvent, calendar_events_controller
|
||||||
from reflector.db.rooms import Room, rooms_controller
|
from reflector.db.rooms import Room, rooms_controller
|
||||||
from reflector.settings import settings
|
from reflector.settings import settings
|
||||||
|
|
||||||
|
logger = structlog.get_logger()
|
||||||
|
|
||||||
|
|
||||||
class SyncStatus(str, Enum):
|
class SyncStatus(str, Enum):
|
||||||
SUCCESS = "success"
|
SUCCESS = "success"
|
||||||
@@ -262,7 +264,7 @@ class ICSSyncService:
|
|||||||
# Check if content changed
|
# Check if content changed
|
||||||
content_hash = hashlib.md5(ics_content.encode()).hexdigest()
|
content_hash = hashlib.md5(ics_content.encode()).hexdigest()
|
||||||
if room.ics_last_etag == content_hash:
|
if room.ics_last_etag == content_hash:
|
||||||
logger.info(f"No changes in ICS for room {room.id}")
|
logger.info("No changes in ICS for room", room_id=room.id)
|
||||||
# Still parse to get event count
|
# Still parse to get event count
|
||||||
calendar = self.fetch_service.parse_ics(ics_content)
|
calendar = self.fetch_service.parse_ics(ics_content)
|
||||||
room_url = f"{settings.UI_BASE_URL}/{room.name}"
|
room_url = f"{settings.UI_BASE_URL}/{room.name}"
|
||||||
@@ -312,7 +314,7 @@ class ICSSyncService:
|
|||||||
}
|
}
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"Failed to sync ICS for room {room.id}: {e}")
|
logger.error("Failed to sync ICS for room", room_id=room.id, error=str(e))
|
||||||
return {"status": SyncStatus.ERROR, "error": str(e)}
|
return {"status": SyncStatus.ERROR, "error": str(e)}
|
||||||
|
|
||||||
def _should_sync(self, room: Room) -> bool:
|
def _should_sync(self, room: Room) -> bool:
|
||||||
|
|||||||
Reference in New Issue
Block a user