From 54dc83a0bab5dd7eccf4dbd4e1befc894b0d2a88 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Sun, 1 Oct 2023 11:27:03 +0200 Subject: [PATCH] Replace `tracing` with `log` --- Cargo.lock | 2 +- ewebsock/Cargo.toml | 2 +- ewebsock/src/native_tungstenite.rs | 6 +++--- ewebsock/src/web.rs | 8 ++++---- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 61a7e47..f66646e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -921,9 +921,9 @@ dependencies = [ "futures", "futures-util", "js-sys", + "log", "tokio", "tokio-tungstenite", - "tracing", "tungstenite", "wasm-bindgen", "wasm-bindgen-futures", diff --git a/ewebsock/Cargo.toml b/ewebsock/Cargo.toml index 505b10f..431871f 100644 --- a/ewebsock/Cargo.toml +++ b/ewebsock/Cargo.toml @@ -32,7 +32,7 @@ with_tungstenite = [ [dependencies] -tracing = "0.1" +log = "0.4" # native: [target.'cfg(not(target_arch = "wasm32"))'.dependencies] diff --git a/ewebsock/src/native_tungstenite.rs b/ewebsock/src/native_tungstenite.rs index 51fe4c5..d9e7eaa 100644 --- a/ewebsock/src/native_tungstenite.rs +++ b/ewebsock/src/native_tungstenite.rs @@ -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(); @@ -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 } } diff --git a/ewebsock/src/web.rs b/ewebsock/src/web.rs index 4ce4e6d..00eb8ee 100644 --- a/ewebsock/src/web.rs +++ b/ewebsock/src/web.rs @@ -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); } } } @@ -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); } } } @@ -98,7 +98,7 @@ pub fn ws_connect(url: String, on_event: EventHandler) -> Result { 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(), )))); @@ -115,7 +115,7 @@ pub fn ws_connect(url: String, on_event: EventHandler) -> Result { { 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()