More precise logging (warn only when returning a 500)

This commit is contained in:
Alex 2021-02-20 00:30:39 +01:00
parent 10b983b8e7
commit 3bcbbe1e31

View file

@ -62,7 +62,11 @@ async fn handler(
let body: Body = Body::from(format!("{}\n", e)); let body: Body = Body::from(format!("{}\n", e));
let mut http_error = Response::new(body); let mut http_error = Response::new(body);
*http_error.status_mut() = e.http_status_code(); *http_error.status_mut() = e.http_status_code();
if e.http_status_code().is_server_error() {
warn!("Response: error {}, {}", e.http_status_code(), e); warn!("Response: error {}, {}", e.http_status_code(), e);
} else {
info!("Response: error {}, {}", e.http_status_code(), e);
}
Ok(http_error) Ok(http_error)
} }
} }