use axum::{body::Body, extract::Request, middleware::Next, response::Response}; use tracing::error; pub async fn log_errors(req: Request, next: Next) -> Response { let method = req.method().clone(); let uri = req.uri().clone(); let response = next.run(req).await; if response.status().is_client_error() || response.status().is_server_error() { error!( method = ?method, uri = ?uri, status = ?response.status(), "Error response returned" ); } response }