Skip to content

Commit

Permalink
LogMiddleware: do something with res.error()
Browse files Browse the repository at this point in the history
  • Loading branch information
Fishrock123 committed Jun 6, 2020
1 parent aaf8ecd commit 5d9b539
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/log/middleware.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,15 @@ impl LogMiddleware {
let start = std::time::Instant::now();
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!("--> Response error", {
message: error.to_string(),
method: method,
path: path,
status: status as u16,
duration: format!("{:?}", start.elapsed()),
});
} else if status.is_client_error() {
} else if status.is_client_error() || status.is_server_error() {
log::warn!("--> Response sent", {
method: method,
path: path,
Expand Down

0 comments on commit 5d9b539

Please sign in to comment.