diff --git a/sim-cli/src/main.rs b/sim-cli/src/main.rs index c706710e..8c777180 100644 --- a/sim-cli/src/main.rs +++ b/sim-cli/src/main.rs @@ -16,19 +16,35 @@ struct Cli { config: PathBuf, #[clap(long, short)] total_time: Option, + #[clap(long, short)] + debug: bool, } #[tokio::main] async fn main() -> anyhow::Result<()> { + let cli = Cli::parse(); + SimpleLogger::new() .with_level(LevelFilter::Warn) - .with_module_level("sim_lib", LevelFilter::Info) - .with_module_level("sim_cli", LevelFilter::Debug) + .with_module_level( + "sim_lib", + if cli.debug { + LevelFilter::Debug + } else { + LevelFilter::Info + }, + ) + .with_module_level( + "sim_cli", + if cli.debug { + LevelFilter::Debug + } else { + LevelFilter::Info + }, + ) .init() .unwrap(); - let cli = Cli::parse(); - let config_str = std::fs::read_to_string(cli.config)?; let Config { nodes, activity } = serde_json::from_str(&config_str)?; diff --git a/sim-lib/src/lib.rs b/sim-lib/src/lib.rs index 9b761072..805221c9 100644 --- a/sim-lib/src/lib.rs +++ b/sim-lib/src/lib.rs @@ -490,11 +490,8 @@ async fn consume_simulation_results( ) { log::debug!("Simulation results consumer started."); - match write_payment_results(receiver, listener).await { - Ok(_) => { - log::debug!("Simulation results ok but exiting!!!"); - } - Err(e) => log::error!("Error while reporting payment results: {:?}", e), + if let Err(e) = write_payment_results(receiver, listener).await { + log::error!("Error while reporting payment results: {:?}", e); } log::debug!("Simulation results consumer exiting"); @@ -659,7 +656,10 @@ async fn track_outcome( log::debug!("Could not send payment result for {:?}.", payment.hash); } } - Err(e) => log::error!("Track payment failed for {:?}: {e}", payment.hash), + Err(e) => log::error!( + "Track payment failed for {}: {e}", + hex::encode(payment.hash.0) + ), } } }