Skip to content

Commit 5723cac

Browse files
authored
Use status code for trace filter message. (#981)
1 parent 11169f2 commit 5723cac

File tree

1 file changed

+32
-28
lines changed

1 file changed

+32
-28
lines changed

src/filters/trace.rs

Lines changed: 32 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -238,35 +238,39 @@ mod internal {
238238
use tracing::Span;
239239

240240
fn finished_logger<E: IsReject>(reply: &Result<(Traced,), E>) {
241-
match reply {
242-
Ok((Traced(resp),)) => {
243-
tracing::info!(target: "warp::filters::trace", status = resp.status().as_u16(), "finished processing with success");
244-
}
245-
Err(e) if e.status().is_server_error() => {
246-
tracing::error!(
247-
target: "warp::filters::trace",
248-
status = e.status().as_u16(),
249-
error = ?e,
250-
"unable to process request (internal error)"
251-
);
252-
}
253-
Err(e) if e.status().is_client_error() => {
254-
tracing::warn!(
255-
target: "warp::filters::trace",
256-
status = e.status().as_u16(),
257-
error = ?e,
258-
"unable to serve request (client error)"
259-
);
260-
}
261-
Err(e) => {
262-
// Either informational or redirect
263-
tracing::info!(
264-
target: "warp::filters::trace",
265-
status = e.status().as_u16(),
266-
result = ?e,
241+
let (status, error) = match reply {
242+
Ok((Traced(resp),)) => (resp.status(), None),
243+
Err(error) => (error.status(), Some(error)),
244+
};
245+
246+
if status.is_success() {
247+
tracing::info!(
248+
target: "warp::filters::trace",
249+
status = status.as_u16(),
250+
"finished processing with success"
251+
);
252+
} else if status.is_server_error() {
253+
tracing::error!(
254+
target: "warp::filters::trace",
255+
status = status.as_u16(),
256+
error = ?error,
257+
"unable to process request (internal error)"
258+
);
259+
} else if status.is_client_error() {
260+
tracing::warn!(
261+
target: "warp::filters::trace",
262+
status = status.as_u16(),
263+
error = ?error,
264+
"unable to serve request (client error)"
265+
);
266+
} else {
267+
// Either informational or redirect
268+
tracing::info!(
269+
target: "warp::filters::trace",
270+
status = status.as_u16(),
271+
error = ?error,
267272
"finished processing with status"
268-
);
269-
}
273+
);
270274
}
271275
}
272276

0 commit comments

Comments
 (0)