try to fix entra

This commit is contained in:
2026-01-15 22:07:32 +01:00
parent e97da03887
commit b61aa68bcd
6 changed files with 628 additions and 79 deletions

View File

@@ -9,7 +9,14 @@ from .config import settings
from .services.provider_manager import provider_manager
# Setup logging
logging.basicConfig(level=logging.INFO)
logging.basicConfig(
level=logging.INFO,
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
handlers=[
logging.FileHandler('/app/devden.log'),
logging.StreamHandler()
]
)
logger = logging.getLogger(__name__)
app = FastAPI(
@@ -30,9 +37,25 @@ app.include_router(auth.router)
app.include_router(chat.router)
@app.exception_handler(Exception)
async def global_exception_handler(request, exc):
"""Global exception handler to log all errors"""
logger.error(f"Unhandled exception: {exc}", {
"url": str(request.url),
"method": request.method,
"headers": dict(request.headers),
"traceback": str(exc)
})
return JSONResponse(
status_code=500,
content={"detail": "Internal server error"}
)
@app.get("/health")
async def health_check():
"""Health check endpoint"""
logger.info("Health check requested")
return JSONResponse(
content={
"status": "healthy",
@@ -41,6 +64,18 @@ async def health_check():
)
@app.get("/logs")
async def get_logs():
"""Get recent log entries (for debugging)"""
try:
with open('/app/devden.log', 'r') as f:
lines = f.readlines()[-50:] # Last 50 lines
return {"logs": lines}
except Exception as e:
logger.error(f"Failed to read logs: {e}")
return {"error": "Failed to read logs"}
@app.on_event("startup")
async def startup_event():
logger.info("DevDen API starting up...")