"""Web logger for the QA agent.""" import json from os import getenv from src.common.logger import log_warning class WebLogger: def __init__(self): """Generate supabase client.""" try: from supabase import create_client self.client = create_client(getenv("SUPABASE_URL"), getenv("SUPABASE_KEY")) except Exception as e: self.client = None log_warning(f"Failed to create supabase client: {e}") def insert( self, question: str, answer: str, history: list[dict], created_at: str ) -> None: """Insert a log into the database.""" if self.client is None: return try: self.client.table("bible_log").insert( { "question": question, "answer": answer, "history": json.dumps(history, ensure_ascii=False), "created_at": created_at, } ).execute() except Exception as e: log_warning(f"로그 저장 중 오류 발생: {e}")