Skip to content

Commit

Permalink
Use status code for trace filter message. (#981)
Browse files Browse the repository at this point in the history
  • Loading branch information
jakajancar committed Jul 6, 2022
1 parent 11169f2 commit 5723cac
Showing 1 changed file with 32 additions and 28 deletions.
60 changes: 32 additions & 28 deletions src/filters/trace.rs
Expand Up @@ -238,35 +238,39 @@ mod internal {
use tracing::Span;

fn finished_logger<E: IsReject>(reply: &Result<(Traced,), E>) {
match reply {
Ok((Traced(resp),)) => {
tracing::info!(target: "warp::filters::trace", status = resp.status().as_u16(), "finished processing with success");
}
Err(e) if e.status().is_server_error() => {
tracing::error!(
target: "warp::filters::trace",
status = e.status().as_u16(),
error = ?e,
"unable to process request (internal error)"
);
}
Err(e) if e.status().is_client_error() => {
tracing::warn!(
target: "warp::filters::trace",
status = e.status().as_u16(),
error = ?e,
"unable to serve request (client error)"
);
}
Err(e) => {
// Either informational or redirect
tracing::info!(
target: "warp::filters::trace",
status = e.status().as_u16(),
result = ?e,
let (status, error) = match reply {
Ok((Traced(resp),)) => (resp.status(), None),
Err(error) => (error.status(), Some(error)),
};

if status.is_success() {
tracing::info!(
target: "warp::filters::trace",
status = status.as_u16(),
"finished processing with success"
);
} else if status.is_server_error() {
tracing::error!(
target: "warp::filters::trace",
status = status.as_u16(),
error = ?error,
"unable to process request (internal error)"
);
} else if status.is_client_error() {
tracing::warn!(
target: "warp::filters::trace",
status = status.as_u16(),
error = ?error,
"unable to serve request (client error)"
);
} else {
// Either informational or redirect
tracing::info!(
target: "warp::filters::trace",
status = status.as_u16(),
error = ?error,
"finished processing with status"
);
}
);
}
}

Expand Down

0 comments on commit 5723cac

Please sign in to comment.