Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ RUN pip install --no-cache-dir -U -r backend/requirements.txt
ENV PYTHONPATH=/app
EXPOSE 8080

ENTRYPOINT ["uvicorn", "backend.main:app", "--host", "0.0.0.0", "--port", "8080", "--workers", "4"]
ENTRYPOINT ["uvicorn", "backend.main:app", "--host", "0.0.0.0", "--port", "8080", "--workers", "4", "--no-access-log"]
2 changes: 1 addition & 1 deletion backend/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,4 @@ async def lifespan(app: FastAPI):
if __name__ == "__main__":
import uvicorn

uvicorn.run(app, host="0.0.0.0", port=8080)
uvicorn.run(app, host="0.0.0.0", port=8080, access_log=False)
12 changes: 11 additions & 1 deletion backend/middleware/logging.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import json
import logging
import time
from fastapi import Request
Expand All @@ -9,6 +10,14 @@
class AccessLogMiddleware(BaseHTTPMiddleware):
async def dispatch(self, request: Request, call_next):
start = time.time()
model = "-"
if request.method in ("POST", "PUT", "PATCH"):
try:
body = await request.body()
data = json.loads(body)
model = data.get("model", "-")
except Exception:
pass
response = await call_next(request)
duration_ms = (time.time() - start) * 1000
token = request.headers.get("authorization", "")
Expand All @@ -17,10 +26,11 @@ async def dispatch(self, request: Request, call_next):
else:
token = "-"
access_logger.info(
"%s %s %s %d %.0fms",
"%s %s %s model=%s %d %.0fms",
token,
request.method,
request.url.path,
model,
response.status_code,
duration_ms,
)
Expand Down
2 changes: 1 addition & 1 deletion backend/redis_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def __init__(
)
# Test connection
self.redis_client.ping()
logger.info(f"Connected to Redis at {self.host}:{self.port}")
logger.debug(f"Connected to Redis at {self.host}:{self.port}")
except Exception as e:
logger.error(f"Failed to connect to Redis: {e}")
# Fallback to in-memory set for development/testing
Expand Down
Loading