Skip to content

Commit

Permalink
Replace tracing with log
Browse files Browse the repository at this point in the history
  • Loading branch information
emilk committed Oct 1, 2023
1 parent 59c3fab commit 54dc83a
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion ewebsock/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ with_tungstenite = [


[dependencies]
tracing = "0.1"
log = "0.4"

# native:
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
Expand Down
6 changes: 3 additions & 3 deletions ewebsock/src/native_tungstenite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ async fn ws_connect_async(
}
};

tracing::info!("WebSocket handshake has been successfully completed");
log::info!("WebSocket handshake has been successfully completed");
on_event(WsEvent::Opened);

let (write, read) = ws_stream.split();
Expand Down Expand Up @@ -98,12 +98,12 @@ pub fn ws_connect_native(url: String, on_event: EventHandler) -> WsSender {
while let Some(item) = rx.recv().await {
yield item;
}
tracing::debug!("WsSender dropped - closing connection.");
log::debug!("WsSender dropped - closing connection.");
};

tokio::spawn(async move {
ws_connect_async(url.clone(), outgoing_messages_stream, on_event).await;
tracing::debug!("WS connection finished.");
log::debug!("WS connection finished.");
});
WsSender { tx }
}
8 changes: 4 additions & 4 deletions ewebsock/src/web.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub struct WsSender {
impl Drop for WsSender {
fn drop(&mut self) {
if let Err(err) = self.ws.close() {
tracing::warn!("Failed to close web-socket: {:?}", err);
log::warn!("Failed to close web-socket: {:?}", err);
}
}
}
Expand All @@ -40,7 +40,7 @@ impl WsSender {
}
};
if let Err(err) = result.map_err(string_from_js_value) {
tracing::error!("Failed to send: {:?}", err);
log::error!("Failed to send: {:?}", err);
}
}
}
Expand Down Expand Up @@ -98,7 +98,7 @@ pub fn ws_connect(url: String, on_event: EventHandler) -> Result<WsSender> {
txt,
))));
} else {
tracing::debug!("Unknown websocket message received: {:?}", e.data());
log::debug!("Unknown websocket message received: {:?}", e.data());
on_event(WsEvent::Message(WsMessage::Unknown(string_from_js_value(
e.data(),
))));
Expand All @@ -115,7 +115,7 @@ pub fn ws_connect(url: String, on_event: EventHandler) -> Result<WsSender> {
{
let on_event = on_event.clone();
let onerror_callback = Closure::wrap(Box::new(move |error_event: web_sys::ErrorEvent| {
tracing::error!(
log::error!(
"error event: {}: {:?}",
error_event.message(),
error_event.error()
Expand Down

0 comments on commit 54dc83a

Please sign in to comment.