LogMiddleware: do something with `res.error()`
Makes use of the newly updated error propgation from
`Response: add optional error storage` for a more
informative error case in the log middleware.
@@ -40,12 +40,22 @@ impl LogMiddleware {
let response = next.run(ctx).await;
let status = response.status();
if status.is_server_error() {
- log::error!("--> Response sent", {
+ if let Some(error) = response.error() {
+ log::error!("Internal error --> Response sent", {
+ message: error.to_string(),
method: method,
path: path,
status: status as u16,
duration: format!("{:?}", start.elapsed()),
});
+ } else {
+ log::error!("Internal error --> Response sent", {
+ method: method,
+ path: path,
+ status: status as u16,
+ duration: format!("{:?}", start.elapsed()),
+ });
+ }
} else if status.is_client_error() {
log::warn!("--> Response sent", {
method: method,
