diff --git a/Cargo.lock b/Cargo.lock index 1e96b564583..c3a8e44c615 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2111,6 +2111,8 @@ dependencies = [ "lazy_static", "rstest", "tokio", + "tracing", + "tracing-subscriber", ] [[package]] diff --git a/crates/apollo_network_benchmark/Cargo.toml b/crates/apollo_network_benchmark/Cargo.toml index 0b2f86ea378..ddbd81f16a4 100644 --- a/crates/apollo_network_benchmark/Cargo.toml +++ b/crates/apollo_network_benchmark/Cargo.toml @@ -9,9 +9,11 @@ license-file.workspace = true testing = [] [dependencies] -clap = { workspace = true, features = ["derive"] } +clap = { workspace = true, features = ["derive", "env"] } lazy_static.workspace = true tokio = { workspace = true, features = ["full", "sync"] } +tracing.workspace = true +tracing-subscriber.workspace = true [dev-dependencies] diff --git a/crates/apollo_network_benchmark/src/bin/broadcast_network_stress_test_node/main.rs b/crates/apollo_network_benchmark/src/bin/broadcast_network_stress_test_node/main.rs index 0d7b655e1a1..efed2aad3d1 100644 --- a/crates/apollo_network_benchmark/src/bin/broadcast_network_stress_test_node/main.rs +++ b/crates/apollo_network_benchmark/src/bin/broadcast_network_stress_test_node/main.rs @@ -1,6 +1,7 @@ //! Runs a node that stress tests the p2p communication of the network. use clap::Parser; +use tracing::Level; #[cfg(test)] mod message_test; @@ -11,6 +12,22 @@ use apollo_network_benchmark::node_args::NodeArgs; #[tokio::main] async fn main() -> Result<(), Box> { - let _args = NodeArgs::parse(); + let args = NodeArgs::parse(); + + let level = match args.user.verbosity { + 0 => None, + 1 => Some(Level::ERROR), + 2 => Some(Level::WARN), + 3 => Some(Level::INFO), + 4 => Some(Level::DEBUG), + _ => Some(Level::TRACE), + }; + tracing::subscriber::set_global_default( + tracing_subscriber::FmtSubscriber::builder().with_max_level(level).finish(), + ) + .expect("Failed to set global default subscriber"); + + println!("Starting network stress test with args:\n{args:?}"); + Ok(()) } diff --git a/crates/apollo_network_benchmark/src/node_args.rs b/crates/apollo_network_benchmark/src/node_args.rs index 7aa189cb471..dac969cd1c8 100644 --- a/crates/apollo_network_benchmark/src/node_args.rs +++ b/crates/apollo_network_benchmark/src/node_args.rs @@ -2,4 +2,23 @@ use clap::Parser; #[derive(Parser, Debug, Clone)] #[command(version, about, long_about = None)] -pub struct NodeArgs {} +/// Arguments from the runner, not meant to be set by the user. +pub struct RunnerArgs {} + +#[derive(Parser, Debug, Clone)] +#[command(version, about, long_about = None)] +/// Arguments from the user. +pub struct UserArgs { + /// Set the verbosity level of the logger, the higher the more verbose + #[arg(short, long, env, default_value = "2")] + pub verbosity: u8, +} + +#[derive(Parser, Debug, Clone)] +#[command(version, about, long_about = None)] +pub struct NodeArgs { + #[command(flatten)] + pub runner: RunnerArgs, + #[command(flatten)] + pub user: UserArgs, +}