Skip to content

Commit

Permalink
Improve debug log fields when executing requests
Browse files Browse the repository at this point in the history
  • Loading branch information
orf committed Nov 12, 2024
1 parent 3dab7b3 commit 3497b12
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 19 deletions.
15 changes: 8 additions & 7 deletions src/blocking/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,18 @@ pub trait Client {
#[instrument(skip(self, req), err)]
fn execute(&self, req: Request<Vec<u8>>) -> Result<Response<Vec<u8>>, ClientError> {
debug!(
"Client sending {} request to {} with {} bytes of data",
req.method().to_string(),
req.uri(),
req.body().len(),
method=%req.method(),
uri=%req.uri(),
len=req.body().len(),
"sending_request",
);
let response = self.send(req)?;

debug!(
"Client received {} response with {} bytes of body data",
response.status().as_u16(),
response.body().len()
status=%response.status(),
len=response.body().len(),
success=response.status().is_success(),
"response_received",
);

// Check response
Expand Down
15 changes: 8 additions & 7 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,18 @@ pub trait Client: Sync + Send {
#[instrument(skip(self, req), err)]
async fn execute(&self, req: Request<Vec<u8>>) -> Result<Response<Vec<u8>>, ClientError> {
debug!(
"Client sending {} request to {} with {} bytes of data",
req.method().to_string(),
req.uri(),
req.body().len(),
method=%req.method(),
uri=%req.uri(),
len=req.body().len(),
"sending_request",
);
let response = self.send(req).await?;

debug!(
"Client received {} response with {} bytes of body data",
response.status().as_u16(),
response.body().len()
status=%response.status(),
len=response.body().len(),
success=response.status().is_success(),
"response_received",
);

// Check response
Expand Down
8 changes: 4 additions & 4 deletions src/endpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ impl<E: Endpoint, M: MiddleWare> Endpoint for MutatedEndpoint<'_, E, M> {
&self,
client: &impl Client,
) -> Result<EndpointResult<Self::Response>, ClientError> {
debug!("Executing endpoint");
trace!("Executing endpoint");

let req = self.request(client.base())?;
let resp = exec_mut(client, self, req, self.middleware).await?;
Expand All @@ -107,7 +107,7 @@ impl<E: Endpoint, M: MiddleWare> Endpoint for MutatedEndpoint<'_, E, M> {
&self,
client: &impl BlockingClient,
) -> Result<EndpointResult<Self::Response>, ClientError> {
debug!("Executing endpoint");
trace!("Executing endpoint");

let req = self.request(client.base())?;
let resp = exec_block_mut(client, self, req, self.middleware)?;
Expand Down Expand Up @@ -232,7 +232,7 @@ pub trait Endpoint: Send + Sync + Sized {
&self,
client: &impl Client,
) -> Result<EndpointResult<Self::Response>, ClientError> {
debug!("Executing endpoint");
trace!("Executing endpoint");

let req = self.request(client.base())?;
let resp = exec(client, req).await?;
Expand All @@ -250,7 +250,7 @@ pub trait Endpoint: Send + Sync + Sized {
&self,
client: &impl BlockingClient,
) -> Result<EndpointResult<Self::Response>, ClientError> {
debug!("Executing endpoint");
trace!("Executing endpoint");

let req = self.request(client.base())?;
let resp = exec_block(client, req)?;
Expand Down
2 changes: 1 addition & 1 deletion src/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ pub fn build_request(
query: Option<String>,
data: Option<Vec<u8>>,
) -> Result<Request<Vec<u8>>, ClientError> {
debug!("Building endpoint request");
trace!("Building endpoint request");
let uri = build_url(base, path, query)?;

let method_err = method.clone();
Expand Down

0 comments on commit 3497b12

Please sign in to comment.