Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

Commit

Permalink
chore: add some traces (#1622)
Browse files Browse the repository at this point in the history
* chore: add some traces

* Update ethers-providers/src/transports/ws.rs

Co-authored-by: Georgios Konstantopoulos <me@gakonst.com>
  • Loading branch information
mattsse and gakonst authored Aug 20, 2022
1 parent 8abb9d8 commit da8c70a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 5 additions & 1 deletion ethers-providers/src/pubsub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use std::{
pin::Pin,
task::{Context, Poll},
};
use tracing::error;

/// A transport implementation supporting pub sub subscriptions.
pub trait PubsubClient: JsonRpcClient {
Expand Down Expand Up @@ -90,7 +91,10 @@ where
match futures_util::ready!(this.rx.poll_next(ctx)) {
Some(item) => match serde_json::from_str(item.get()) {
Ok(res) => Poll::Ready(Some(res)),
_ => Poll::Pending,
Err(err) => {
error!("failed to deserialize item {:?}", err);
Poll::Pending
}
},
None => Poll::Ready(None),
}
Expand Down
2 changes: 2 additions & 0 deletions ethers-providers/src/transports/ws.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ use std::{
},
};
use thiserror::Error;
use tracing::trace;

use super::common::{Params, Response};

Expand Down Expand Up @@ -317,6 +318,7 @@ where
}

async fn handle_text(&mut self, inner: String) -> Result<(), ClientError> {
trace!(msg=?inner, "received message");
let (id, result) = match serde_json::from_str(&inner)? {
Response::Success { id, result } => (id, Ok(result.to_owned())),
Response::Error { id, error } => (id, Err(error)),
Expand Down

0 comments on commit da8c70a

Please sign in to comment.