diff --git a/server/middleware.py b/server/middleware.py index a0f2990..00329cc 100644 --- a/server/middleware.py +++ b/server/middleware.py @@ -157,15 +157,22 @@ class LoggingMiddleware(BaseHTTPMiddleware): # Return 404 without logging - confuse the bots return Response(status_code=404, content="") - # Log legitimate requests + # Skip logging for large file downloads (don't spam logs) + is_file_download = path.startswith("/pack/") and "/file/" in path + + # Log legitimate requests (except file downloads) start_time = time.time() - logger.info(f"→ {request.method} {path} (IP: {client_ip}, ID: {request_id})") + if not is_file_download: + logger.info(f"→ {request.method} {path} (IP: {client_ip}, ID: {request_id})") try: response = await call_next(request) duration = (time.time() - start_time) * 1000 - logger.info(f"← {request.method} {path} → {response.status_code} ({duration:.0f}ms) [ID: {request_id}]") + + if not is_file_download: + logger.info(f"← {request.method} {path} → {response.status_code} ({duration:.0f}ms) [ID: {request_id}]") + response.headers["X-Request-ID"] = request_id return response