From 6753fe01a12447c245eaee8d6806f3528f97c750 Mon Sep 17 00:00:00 2001 From: John Smith Date: Sat, 10 Dec 2022 13:16:26 -0500 Subject: [PATCH] log cleanup --- veilid-core/src/network_manager/mod.rs | 10 +++++----- veilid-core/src/network_manager/native/mod.rs | 2 +- .../network_manager/native/network_class_discovery.rs | 2 +- veilid-core/src/network_manager/native/protocol/udp.rs | 2 +- veilid-core/src/network_manager/network_connection.rs | 2 +- veilid-core/src/routing_table/mod.rs | 4 ++-- veilid-core/src/rpc_processor/mod.rs | 9 ++------- .../src/rpc_processor/rpc_validate_dial_info.rs | 4 ++-- veilid-flutter/lib/veilid.dart | 4 ++-- veilid-tools/src/network_result.rs | 2 +- 10 files changed, 18 insertions(+), 23 deletions(-) diff --git a/veilid-core/src/network_manager/mod.rs b/veilid-core/src/network_manager/mod.rs index 56b95702..cb3672ac 100644 --- a/veilid-core/src/network_manager/mod.rs +++ b/veilid-core/src/network_manager/mod.rs @@ -814,7 +814,7 @@ impl NetworkManager { // Send receipt directly log_net!(debug "send_out_of_band_receipt: dial_info={}", dial_info); - network_result_value_or_log!(debug self + network_result_value_or_log!(self .net() .send_data_unbound_to_dial_info(dial_info, rcpt_data) .await? => { @@ -1243,7 +1243,7 @@ impl NetworkManager { let timeout_ms = self.with_config(|c| c.network.rpc.timeout_ms); // Send boot magic to requested peer address let data = BOOT_MAGIC.to_vec(); - let out_data: Vec = network_result_value_or_log!(debug self + let out_data: Vec = network_result_value_or_log!(self .net() .send_recv_data_unbound_to_dial_info(dial_info, data, timeout_ms) .await? => @@ -1315,13 +1315,13 @@ impl NetworkManager { // Is this a direct bootstrap request instead of an envelope? if data[0..4] == *BOOT_MAGIC { - network_result_value_or_log!(debug self.handle_boot_request(connection_descriptor).await? => {}); + network_result_value_or_log!(self.handle_boot_request(connection_descriptor).await? => {}); return Ok(true); } // Is this an out-of-band receipt instead of an envelope? if data[0..4] == *RECEIPT_MAGIC { - network_result_value_or_log!(debug self.handle_out_of_band_receipt(data).await => {}); + network_result_value_or_log!(self.handle_out_of_band_receipt(data).await => {}); return Ok(true); } @@ -1396,7 +1396,7 @@ impl NetworkManager { if let Some(relay_nr) = some_relay_nr { // Relay the packet to the desired destination log_net!("relaying {} bytes to {}", data.len(), relay_nr); - network_result_value_or_log!(debug self.send_data(relay_nr, data.to_vec()) + network_result_value_or_log!(self.send_data(relay_nr, data.to_vec()) .await .wrap_err("failed to forward envelope")? => { return Ok(false); diff --git a/veilid-core/src/network_manager/native/mod.rs b/veilid-core/src/network_manager/native/mod.rs index de848990..9a532d3a 100644 --- a/veilid-core/src/network_manager/native/mod.rs +++ b/veilid-core/src/network_manager/native/mod.rs @@ -512,7 +512,7 @@ impl Network { &peer_socket_addr, &descriptor.local().map(|sa| sa.to_socket_addr()), ) { - network_result_value_or_log!(debug ph.clone() + network_result_value_or_log!(ph.clone() .send_message(data.clone(), peer_socket_addr) .await .wrap_err("sending data to existing conection")? => { return Ok(Some(data)); } ); diff --git a/veilid-core/src/network_manager/native/network_class_discovery.rs b/veilid-core/src/network_manager/native/network_class_discovery.rs index 3f7e6122..86acc197 100644 --- a/veilid-core/src/network_manager/native/network_class_discovery.rs +++ b/veilid-core/src/network_manager/native/network_class_discovery.rs @@ -83,7 +83,7 @@ impl DiscoveryContext { async fn request_public_address(&self, node_ref: NodeRef) -> Option { let rpc = self.routing_table.rpc_processor(); - let res = network_result_value_or_log!(debug match rpc.rpc_call_status(Destination::direct(node_ref.clone())).await { + let res = network_result_value_or_log!(match rpc.rpc_call_status(Destination::direct(node_ref.clone())).await { Ok(v) => v, Err(e) => { log_net!(error diff --git a/veilid-core/src/network_manager/native/protocol/udp.rs b/veilid-core/src/network_manager/native/protocol/udp.rs index 6af66b1d..a8fe5ce8 100644 --- a/veilid-core/src/network_manager/native/protocol/udp.rs +++ b/veilid-core/src/network_manager/native/protocol/udp.rs @@ -14,7 +14,7 @@ impl RawUdpProtocolHandler { // #[instrument(level = "trace", err, skip(self, data), fields(data.len = data.len(), ret.len, ret.descriptor))] pub async fn recv_message(&self, data: &mut [u8]) -> io::Result<(usize, ConnectionDescriptor)> { let (size, descriptor) = loop { - let (size, remote_addr) = network_result_value_or_log!(debug self.socket.recv_from(data).await.into_network_result()? => continue); + let (size, remote_addr) = network_result_value_or_log!(self.socket.recv_from(data).await.into_network_result()? => continue); if size > MAX_MESSAGE_SIZE { log_net!(debug "{}({}) at {}@{}:{}", "Invalid message".green(), "received too large UDP message", file!(), line!(), column!()); continue; diff --git a/veilid-core/src/network_manager/network_connection.rs b/veilid-core/src/network_manager/network_connection.rs index 3d410615..3b573835 100644 --- a/veilid-core/src/network_manager/network_connection.rs +++ b/veilid-core/src/network_manager/network_connection.rs @@ -301,7 +301,7 @@ impl NetworkConnection { match res { Ok(v) => { - let message = network_result_value_or_log!(debug v => { + let message = network_result_value_or_log!(v => { return RecvLoopAction::Finish; }); diff --git a/veilid-core/src/routing_table/mod.rs b/veilid-core/src/routing_table/mod.rs index b51ef048..32ff20d3 100644 --- a/veilid-core/src/routing_table/mod.rs +++ b/veilid-core/src/routing_table/mod.rs @@ -891,7 +891,7 @@ impl RoutingTable { // and then contact those nodes to inform -them- that we exist // Ask bootstrap server for nodes closest to our own node - let closest_nodes = network_result_value_or_log!(debug match self.find_self(node_ref.clone()).await { + let closest_nodes = network_result_value_or_log!(match self.find_self(node_ref.clone()).await { Err(e) => { log_rtab!(error "find_self failed for {:?}: {:?}", @@ -907,7 +907,7 @@ impl RoutingTable { // Ask each node near us to find us as well if wide { for closest_nr in closest_nodes { - network_result_value_or_log!(debug match self.find_self(closest_nr.clone()).await { + network_result_value_or_log!(match self.find_self(closest_nr.clone()).await { Err(e) => { log_rtab!(error "find_self failed for {:?}: {:?}", diff --git a/veilid-core/src/rpc_processor/mod.rs b/veilid-core/src/rpc_processor/mod.rs index f4d052be..149c3b8c 100644 --- a/veilid-core/src/rpc_processor/mod.rs +++ b/veilid-core/src/rpc_processor/mod.rs @@ -1344,13 +1344,8 @@ impl RPCProcessor { Ok(v) => v, }; - cfg_if::cfg_if! { - if #[cfg(debug_assertions)] { - network_result_value_or_log!(warn res => {}); - } else { - network_result_value_or_log!(debug res => {}); - } - } + + network_result_value_or_log!(res => {}); } } diff --git a/veilid-core/src/rpc_processor/rpc_validate_dial_info.rs b/veilid-core/src/rpc_processor/rpc_validate_dial_info.rs index d1910709..df1a58a2 100644 --- a/veilid-core/src/rpc_processor/rpc_validate_dial_info.rs +++ b/veilid-core/src/rpc_processor/rpc_validate_dial_info.rs @@ -26,7 +26,7 @@ impl RPCProcessor { // Send the validate_dial_info request // This can only be sent directly, as relays can not validate dial info - network_result_value_or_log!(debug self.statement(Destination::direct(peer), statement) + network_result_value_or_log!(self.statement(Destination::direct(peer), statement) .await? => { return Ok(false); } @@ -144,7 +144,7 @@ impl RPCProcessor { // Send the validate_dial_info request // This can only be sent directly, as relays can not validate dial info - network_result_value_or_log!(debug self.statement(Destination::direct(peer), statement) + network_result_value_or_log!(self.statement(Destination::direct(peer), statement) .await? => { continue; } diff --git a/veilid-flutter/lib/veilid.dart b/veilid-flutter/lib/veilid.dart index e85a9262..9b194c02 100644 --- a/veilid-flutter/lib/veilid.dart +++ b/veilid-flutter/lib/veilid.dart @@ -1474,8 +1474,8 @@ class VeilidStateRoute { }); VeilidStateRoute.fromJson(Map json) - : deadRoutes = jsonDecode(json['dead_routes']), - deadRemoteRoutes = jsonDecode(json['dead_remote_routes']); + : deadRoutes = json['dead_routes'], + deadRemoteRoutes = json['dead_remote_routes']; Map get json { return {'dead_routes': deadRoutes, 'dead_remote_routes': deadRemoteRoutes}; diff --git a/veilid-tools/src/network_result.rs b/veilid-tools/src/network_result.rs index 306f9ffd..55145cf5 100644 --- a/veilid-tools/src/network_result.rs +++ b/veilid-tools/src/network_result.rs @@ -328,7 +328,7 @@ macro_rules! log_network_result { #[macro_export] macro_rules! network_result_value_or_log { - ($level: ident $r: expr => $f:tt) => { + ($r: expr => $f:tt) => { match $r { NetworkResult::Timeout => { log_network_result!(