From ff0cee58d55061f382ccea9f2f6501f7db1ec167 Mon Sep 17 00:00:00 2001 From: ddidderr Date: Tue, 12 Nov 2024 22:56:49 +0100 Subject: [PATCH] [logging] tiny improvements, still the WASM stacktrace error --- crates/lanspread-client/src/lib.rs | 18 +++++++----------- .../src-tauri/src/lib.rs | 8 ++++++-- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/crates/lanspread-client/src/lib.rs b/crates/lanspread-client/src/lib.rs index ac17961..fb06960 100644 --- a/crates/lanspread-client/src/lib.rs +++ b/crates/lanspread-client/src/lib.rs @@ -91,24 +91,20 @@ pub async fn run( log::error!("failed to send request to server {:?}", e); } - let mut all_data: Vec = Vec::new(); - while let Ok(Some(data)) = rx.receive().await { - log::trace!("msg from server (raw): {}", String::from_utf8_lossy(&data)); - all_data.extend_from_slice(&data); + let mut data: Vec = Vec::new(); + while let Ok(Some(bytes)) = rx.receive().await { + data.extend_from_slice(&bytes); } - log::debug!("{} bytes received from server", all_data.len()); - log::trace!( - "server response (RAW): {}", - String::from_utf8_lossy(&all_data) - ); + log::debug!("{} bytes received from server", data.len()); + log::trace!("server response (RAW): {}", String::from_utf8_lossy(&data)); - let response = Response::decode(&all_data); + let response = Response::decode(&data); log::trace!("server response (DECODED): {response:?}"); match response { Response::Games(games) => { for game in &games { - log::debug!("{game:?}"); + log::debug!("{game}"); } if let Err(e) = tx_notify_ui.send(ClientEvent::ListGames(games)) { diff --git a/crates/lanspread-tauri-leptos/src-tauri/src/lib.rs b/crates/lanspread-tauri-leptos/src-tauri/src/lib.rs index 18f797e..27f4ccb 100755 --- a/crates/lanspread-tauri-leptos/src-tauri/src/lib.rs +++ b/crates/lanspread-tauri-leptos/src-tauri/src/lib.rs @@ -108,10 +108,14 @@ pub fn run() { let app_handle = app.handle().clone(); tauri::async_runtime::spawn(async move { while let Some(event) = rx_client_event.recv().await { - log::debug!("Received client event"); - match event { ClientEvent::ListGames(games) => { + log::debug!("Received client event: ListGames"); + + for game in &games { + log::trace!("client event ListGames iter: {game:?}"); + } + if let Err(e) = app_handle.emit("games-list-updated", Some(games)) { log::error!("Failed to emit games-list-updated event: {e}"); } else {