Skip to content

Commit

Permalink
Merge pull request #71 from sr-gi/debug-arg
Browse files Browse the repository at this point in the history
Adds debug arg to the CLI
  • Loading branch information
carlaKC authored Aug 24, 2023
2 parents df54576 + dd699eb commit f57ff45
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 10 deletions.
24 changes: 20 additions & 4 deletions sim-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,35 @@ struct Cli {
config: PathBuf,
#[clap(long, short)]
total_time: Option<u32>,
#[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)?;

Expand Down
12 changes: 6 additions & 6 deletions sim-lib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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)
),
}
}
}
Expand Down

0 comments on commit f57ff45

Please sign in to comment.