graphiti_service.py: add traceback logging, log file handler for all endpoints
This commit is contained in:
@@ -4,7 +4,7 @@ Wraps graphiti-core in a FastAPI service to avoid asyncio event loop conflicts.
|
||||
Port 8001 (internal only). No OpenAI dependency.
|
||||
"""
|
||||
|
||||
import os, logging, sys
|
||||
import os, logging, sys, traceback
|
||||
from contextlib import asynccontextmanager
|
||||
from datetime import datetime
|
||||
from pathlib import Path
|
||||
@@ -15,7 +15,14 @@ from pydantic import BaseModel
|
||||
|
||||
load_dotenv(Path.home() / "aaronai" / ".env")
|
||||
|
||||
logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(name)s - %(levelname)s - %(message)s")
|
||||
logging.basicConfig(
|
||||
level=logging.INFO,
|
||||
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
|
||||
handlers=[
|
||||
logging.FileHandler("/var/log/aaronai/graphiti-sidecar.log"),
|
||||
logging.StreamHandler(),
|
||||
]
|
||||
)
|
||||
log = logging.getLogger("graphiti-sidecar")
|
||||
|
||||
GROUP_ID = os.getenv("GRAPHITI_GROUP_ID", "aaron")
|
||||
@@ -116,7 +123,7 @@ async def add_episode(req: EpisodeRequest):
|
||||
)
|
||||
return {"ok": True}
|
||||
except Exception as e:
|
||||
log.error(f"Episode ingestion failed: {e}")
|
||||
log.error(f"Episode ingestion failed: {e}\n{traceback.format_exc()}")
|
||||
raise HTTPException(status_code=500, detail=str(e))
|
||||
|
||||
@app.post("/episodes/bulk")
|
||||
@@ -142,7 +149,7 @@ async def add_episodes_bulk(req: BulkEpisodeRequest):
|
||||
)
|
||||
return {"ok": True, "count": len(raw_episodes)}
|
||||
except Exception as e:
|
||||
log.error(f"Bulk ingestion failed: {e}")
|
||||
log.error(f"Bulk ingestion failed: {e}\n{traceback.format_exc()}")
|
||||
raise HTTPException(status_code=500, detail=str(e))
|
||||
|
||||
|
||||
@@ -168,7 +175,7 @@ async def search(query: str, limit: int = 8, group_id: str | None = None):
|
||||
]
|
||||
}
|
||||
except Exception as e:
|
||||
log.error(f"Search failed: {e}")
|
||||
log.error(f"Search failed: {e}\n{traceback.format_exc()}")
|
||||
raise HTTPException(status_code=500, detail=str(e))
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in New Issue
Block a user