from datetime import date
from health.services.obsidian import ObsidianSyncService
from health.utils.logging_config import setup_logger

logger = setup_logger(__name__)

class ObsidianTool:
    @staticmethod
    def sync_obsidian(target_date: str) -> str:
        """Sync Obsidian daily note for a date."""
        try:
            date_obj = date.fromisoformat(target_date)
            service = ObsidianSyncService()
            success = service.sync_daily_note(date_obj)
            
            if success:
                return f"Successfully synced Obsidian note for {target_date}"
            else:
                return f"Failed to sync Obsidian note for {target_date} (File not found or no data)"
        except Exception as e:
            logger.error(f"Obsidian sync error: {e}")
            return f"Error syncing Obsidian: {str(e)}"
