From f80a26f48a091b135e4990437a91f72935b28d23 Mon Sep 17 00:00:00 2001 From: ryardley Date: Sun, 22 Dec 2024 22:05:11 +1100 Subject: [PATCH] remove println --- packages/ciphernode/config/src/app_config.rs | 1 - packages/ciphernode/net/src/dialer.rs | 15 ++++++++------- packages/ciphernode/net/src/network_peer.rs | 6 +++--- packages/ciphernode/net/src/retry.rs | 5 +++-- 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/packages/ciphernode/config/src/app_config.rs b/packages/ciphernode/config/src/app_config.rs index d821b29e..cc6eac80 100644 --- a/packages/ciphernode/config/src/app_config.rs +++ b/packages/ciphernode/config/src/app_config.rs @@ -273,7 +273,6 @@ pub fn load_config(config_file: Option<&str>) -> Result { } let with_envs = load_yaml_with_env(&defaults.config_file())?; - println!("{}", with_envs); let config = Figment::from(Serialized::defaults(&defaults)) .merge(Yaml::string(&with_envs)) diff --git a/packages/ciphernode/net/src/dialer.rs b/packages/ciphernode/net/src/dialer.rs index f684c50b..f11d6396 100644 --- a/packages/ciphernode/net/src/dialer.rs +++ b/packages/ciphernode/net/src/dialer.rs @@ -6,6 +6,7 @@ use libp2p::{ swarm::{dial_opts::DialOpts, ConnectionId, DialError}, Multiaddr, }; +use tracing::info; use std::net::ToSocketAddrs; use tokio::sync::{broadcast, mpsc}; use tracing::error; @@ -22,7 +23,7 @@ async fn dial_multiaddr( multiaddr_str: &str, ) -> Result<()> { let multiaddr = &multiaddr_str.parse()?; - println!("Now dialing in to {}", multiaddr); + info!("Now dialing in to {}", multiaddr); retry_with_backoff( || attempt_connection(cmd_tx, event_tx, multiaddr), BACKOFF_MAX_RETRIES, @@ -68,7 +69,7 @@ async fn attempt_connection( let multi = get_resolved_multiaddr(multiaddr).map_err(to_retry)?; let opts: DialOpts = multi.clone().into(); let dial_connection = opts.connection_id(); - println!("Dialing: '{}' with connection '{}'", multi, dial_connection); + info!("Dialing: '{}' with connection '{}'", multi, dial_connection); cmd_tx .send(NetworkPeerCommand::Dial(opts)) .await @@ -86,16 +87,16 @@ async fn wait_for_connection( match event_rx.recv().await.map_err(to_retry)? { NetworkPeerEvent::ConnectionEstablished { connection_id } => { if connection_id == dial_connection { - println!("Connection Established"); + info!("Connection Established"); return Ok(()); } } NetworkPeerEvent::DialError { error } => { - println!("DialError!"); + info!("DialError!"); return match error.as_ref() { // If we are dialing ourself then we should just fail DialError::NoAddresses { .. } => { - println!("DialError received. Returning RetryError::Failure"); + info!("DialError received. Returning RetryError::Failure"); Err(RetryError::Failure(error.clone().into())) } // Try again otherwise @@ -106,9 +107,9 @@ async fn wait_for_connection( connection_id, error, } => { - println!("OutgoingConnectionError!"); + info!("OutgoingConnectionError!"); if connection_id == dial_connection { - println!( + info!( "Connection {} failed because of error {}. Retrying...", connection_id, error ); diff --git a/packages/ciphernode/net/src/network_peer.rs b/packages/ciphernode/net/src/network_peer.rs index 677a1f06..e202e061 100644 --- a/packages/ciphernode/net/src/network_peer.rs +++ b/packages/ciphernode/net/src/network_peer.rs @@ -137,11 +137,11 @@ impl NetworkPeer { } }, NetworkPeerCommand::Dial(multi) => { - println!("DIAL: {:?}", multi); + info!("DIAL: {:?}", multi); match self.swarm.dial(multi) { - Ok(v) => println!("Dial returned {:?}", v), + Ok(v) => info!("Dial returned {:?}", v), Err(error) => { - println!("Dialing error! {}", error); + info!("Dialing error! {}", error); event_tx.send(NetworkPeerEvent::DialError { error: error.into() })?; } } diff --git a/packages/ciphernode/net/src/retry.rs b/packages/ciphernode/net/src/retry.rs index 5065c467..f45ef27d 100644 --- a/packages/ciphernode/net/src/retry.rs +++ b/packages/ciphernode/net/src/retry.rs @@ -1,4 +1,5 @@ use anyhow::Result; +use tracing::{error, warn}; use std::{future::Future, time::Duration}; use tokio::time::sleep; @@ -49,7 +50,7 @@ where )); } - println!( + warn!( "Attempt {}/{} failed, retrying in {}ms: {}", current_attempt, max_attempts, delay_ms, e ); @@ -59,7 +60,7 @@ where delay_ms *= 2; // Exponential backoff } RetryError::Failure(e) => { - println!("FAILURE!: returning to caller."); + error!("FAILURE!: returning to caller."); return Err(e); } }