Skip to content

Commit

Permalink
server: Log HTTP response code as u16
Browse files Browse the repository at this point in the history
Currently HTTP response codes are generally logged as strings, which is
a bit unintuitive as these are integers.

Log the response code as a numeric value.
  • Loading branch information
wfchandler committed Feb 27, 2025
1 parent f7f7d37 commit 9b3d7b8
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions dropshot/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -853,7 +853,7 @@ async fn http_request_handle_wrap<C: ServerContext>(

// TODO-debug: add request and response headers here
info!(request_log, "request completed";
"response_code" => status.as_str(),
"response_code" => status.as_u16(),
"latency_us" => latency_us,
"error_message_internal" => message_internal,
"error_message_external" => message_external,
Expand All @@ -865,7 +865,7 @@ async fn http_request_handle_wrap<C: ServerContext>(
Ok(response) => {
// TODO-debug: add request and response headers here
info!(request_log, "request completed";
"response_code" => response.status().as_str(),
"response_code" => response.status().as_u16(),
"latency_us" => latency_us,
);

Expand Down Expand Up @@ -942,11 +942,11 @@ async fn http_request_handle<C: ServerContext>(
match result {
Ok(r) => warn!(
request_log, "request completed after handler was already cancelled";
"response_code" => r.status().as_str(),
"response_code" => r.status().as_u16(),
),
Err(error) => {
warn!(request_log, "request completed after handler was already cancelled";
"response_code" => %error.status_code(),
"response_code" => error.status_code().as_u16(),
"error_message_internal" => error.internal_message(),
"error_message_external" => error.external_message(),,
);
Expand Down

0 comments on commit 9b3d7b8

Please sign in to comment.