diff --git a/src/blueapi/service/main.py b/src/blueapi/service/main.py index 432cc5455..1296bec58 100644 --- a/src/blueapi/service/main.py +++ b/src/blueapi/service/main.py @@ -594,16 +594,19 @@ def start(config: ApplicationConfig): async def log_request_details( request: Request, call_next: Callable[[Request], Awaitable[StreamingResponse]] ) -> Response: - """Middleware to log all request's host, method, path, status and request and - body""" - log = LOGGER.debug if request.url.path == "/healthz" else LOGGER.info + """Middleware to log request's host, method, path, status and request and + body + + Logs GET as debug, all else as info.""" + log = LOGGER.debug if request.method == "GET" else LOGGER.info request_body = await request.body() client = request.client or Address("Unknown", -1) log_message = f"{client.host}:{client.port} {request.method} {request.url.path}" extra = { "request_body": request_body, } - log(log_message, extra=extra) + if request.method != "GET": + log(log_message, extra=extra) response = await call_next(request) log_message += f" {response.status_code}"