Skip to content

Commit

Permalink
remove println
Browse files Browse the repository at this point in the history
  • Loading branch information
ryardley committed Dec 22, 2024
1 parent c6f0e11 commit f80a26f
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 13 deletions.
1 change: 0 additions & 1 deletion packages/ciphernode/config/src/app_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,6 @@ pub fn load_config(config_file: Option<&str>) -> Result<AppConfig> {
}

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))
Expand Down
15 changes: 8 additions & 7 deletions packages/ciphernode/net/src/dialer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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,
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
);
Expand Down
6 changes: 3 additions & 3 deletions packages/ciphernode/net/src/network_peer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() })?;
}
}
Expand Down
5 changes: 3 additions & 2 deletions packages/ciphernode/net/src/retry.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use anyhow::Result;
use tracing::{error, warn};
use std::{future::Future, time::Duration};
use tokio::time::sleep;

Expand Down Expand Up @@ -49,7 +50,7 @@ where
));
}

println!(
warn!(
"Attempt {}/{} failed, retrying in {}ms: {}",
current_attempt, max_attempts, delay_ms, e
);
Expand All @@ -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);
}
}
Expand Down

0 comments on commit f80a26f

Please sign in to comment.