Skip to content

Commit

Permalink
Lower log-level of messages of tungstenite and ws-rpc clients (#674)
Browse files Browse the repository at this point in the history
  • Loading branch information
haerdib authored Nov 20, 2023
1 parent 97ef743 commit b722ac4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
9 changes: 3 additions & 6 deletions src/rpc/tungstenite_client/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ impl TungsteniteRpcClient {

let msg = read_until_text_message(&mut socket)?;

debug!("Got get_request_msg {}", msg);
trace!("Got get_request_msg {}", msg);
let result_str =
serde_json::from_str(msg.as_str()).map(|v: Value| v["result"].to_string())?;
Ok(result_str)
Expand Down Expand Up @@ -165,7 +165,7 @@ fn send_message_to_client(
message: &str,
subscription_id: &str,
) -> Result<()> {
info!("got on_subscription_msg {}", message);
trace!("got on_subscription_msg {}", message);
let value: Value = serde_json::from_str(message)?;

if helpers::subscription_id_matches(&value, subscription_id) {
Expand Down Expand Up @@ -193,10 +193,7 @@ fn attempt_connection_until(url: &Url, max_attempts: u8) -> Result<(MySocket, Re
fn read_until_text_message(socket: &mut MySocket) -> Result<String> {
loop {
match socket.read()? {
Message::Text(s) => {
debug!("receive text: {:?}", s);
break Ok(s)
},
Message::Text(s) => break Ok(s),
Message::Binary(_) => {
debug!("skip binary msg");
},
Expand Down
6 changes: 3 additions & 3 deletions src/rpc/ws_client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ where
MessageHandler::Context: From<MessageContext<MessageHandler::ThreadMessage>>,
{
fn on_open(&mut self, _: Handshake) -> WsResult<()> {
info!("sending request: {}", self.request);
trace!("sending request: {}", self.request);
self.out.send(self.request.clone())?;
Ok(())
}
Expand Down Expand Up @@ -91,7 +91,7 @@ impl HandleMessage for RequestHandler {
out.close(CloseCode::Normal)
.unwrap_or_else(|_| warn!("Could not close Websocket normally"));

info!("Got get_request_msg {}", msg);
trace!("Got get_request_msg {}", msg);
let result_str = serde_json::from_str(msg.as_text()?)
.map(|v: serde_json::Value| v["result"].to_string())
.map_err(RpcClientError::SerdeJson);
Expand All @@ -114,7 +114,7 @@ impl HandleMessage for SubscriptionHandler {
let out = &context.out;
let msg = &context.msg.as_text()?;

info!("got on_subscription_msg {}", msg);
trace!("got on_subscription_msg {}", msg);
let value: serde_json::Value = serde_json::from_str(msg).map_err(Box::new)?;

let send_result = match self.subscription_id.as_ref() {
Expand Down

0 comments on commit b722ac4

Please sign in to comment.