From f650107a13c8a8d01406c77d3398d5719db951eb Mon Sep 17 00:00:00 2001 From: Yihau Chen Date: Thu, 14 Mar 2024 20:35:33 +0800 Subject: [PATCH] [anza migration]: add 'agave=info' to default log level (#223) --- accounts-db/store-tool/src/main.rs | 2 +- bench-tps/src/main.rs | 2 +- cargo-registry/src/main.rs | 2 +- dos/src/main.rs | 2 +- faucet/src/bin/faucet.rs | 2 +- gossip/src/main.rs | 2 +- ledger-tool/src/main.rs | 2 +- logger/src/lib.rs | 7 +++++++ scripts/run.sh | 2 +- transaction-dos/src/main.rs | 2 +- validator/src/lib.rs | 5 ++--- watchtower/src/main.rs | 2 +- 12 files changed, 19 insertions(+), 13 deletions(-) diff --git a/accounts-db/store-tool/src/main.rs b/accounts-db/store-tool/src/main.rs index cb5838af4f21ad..86482feb2afda8 100644 --- a/accounts-db/store-tool/src/main.rs +++ b/accounts-db/store-tool/src/main.rs @@ -13,7 +13,7 @@ use { }; fn main() { - solana_logger::setup_with_default("solana=info"); + solana_logger::setup_with_default_filter(); let matches = App::new(crate_name!()) .about(crate_description!()) .version(solana_version::version!()) diff --git a/bench-tps/src/main.rs b/bench-tps/src/main.rs index fa0fc1509055e4..d3def39ed4d383 100644 --- a/bench-tps/src/main.rs +++ b/bench-tps/src/main.rs @@ -168,7 +168,7 @@ fn create_client( } fn main() { - solana_logger::setup_with_default("solana=info"); + solana_logger::setup_with_default_filter(); solana_metrics::set_panic_hook("bench-tps", /*version:*/ None); let matches = cli::build_args(solana_version::version!()).get_matches(); diff --git a/cargo-registry/src/main.rs b/cargo-registry/src/main.rs index 0bfc2c7f3ff004..317e86341927f7 100644 --- a/cargo-registry/src/main.rs +++ b/cargo-registry/src/main.rs @@ -263,7 +263,7 @@ impl CargoRegistryService { #[tokio::main] async fn main() { - solana_logger::setup_with_default("solana=info"); + solana_logger::setup_with_default_filter(); let client = Arc::new(Client::new().expect("Failed to get RPC Client instance")); let bind_addr = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)), client.port); diff --git a/dos/src/main.rs b/dos/src/main.rs index 577e4a2d067393..3bf7cce0e782cc 100644 --- a/dos/src/main.rs +++ b/dos/src/main.rs @@ -760,7 +760,7 @@ fn run_dos( } fn main() { - solana_logger::setup_with_default("solana=info"); + solana_logger::setup_with_default_filter(); let cmd_params = build_cli_parameters(); let (nodes, client) = if !cmd_params.skip_gossip { diff --git a/faucet/src/bin/faucet.rs b/faucet/src/bin/faucet.rs index 8e45ef98155a54..56cc7542623185 100644 --- a/faucet/src/bin/faucet.rs +++ b/faucet/src/bin/faucet.rs @@ -19,7 +19,7 @@ use { async fn main() { let default_keypair = solana_cli_config::Config::default().keypair_path; - solana_logger::setup_with_default("solana=info"); + solana_logger::setup_with_default_filter(); solana_metrics::set_panic_hook("faucet", /*version:*/ None); let matches = App::new(crate_name!()) .about(crate_description!()) diff --git a/gossip/src/main.rs b/gossip/src/main.rs index 226fab8d9d43a8..1f31195f431d36 100644 --- a/gossip/src/main.rs +++ b/gossip/src/main.rs @@ -326,7 +326,7 @@ fn process_rpc_url( } fn main() -> Result<(), Box> { - solana_logger::setup_with_default("solana=info"); + solana_logger::setup_with_default_filter(); let matches = parse_matches(); let socket_addr_space = SocketAddrSpace::new(matches.is_present("allow_private_addr")); diff --git a/ledger-tool/src/main.rs b/ledger-tool/src/main.rs index 94298623e953cd..4509e975cf10a1 100644 --- a/ledger-tool/src/main.rs +++ b/ledger-tool/src/main.rs @@ -555,7 +555,7 @@ fn main() { const DEFAULT_MAX_FULL_SNAPSHOT_ARCHIVES_TO_RETAIN: usize = std::usize::MAX; const DEFAULT_MAX_INCREMENTAL_SNAPSHOT_ARCHIVES_TO_RETAIN: usize = std::usize::MAX; - solana_logger::setup_with_default("solana=info"); + solana_logger::setup_with_default_filter(); let no_snapshot_arg = Arg::with_name("no_snapshot") .long("no-snapshot") diff --git a/logger/src/lib.rs b/logger/src/lib.rs index 6cc57e81c531f3..8d6a20662c2c29 100644 --- a/logger/src/lib.rs +++ b/logger/src/lib.rs @@ -10,6 +10,8 @@ lazy_static! { Arc::new(RwLock::new(env_logger::Logger::from_default_env())); } +pub const DEFAULT_FILTER: &str = "solana=info,agave=info"; + struct LoggerShim {} impl log::Log for LoggerShim { @@ -49,6 +51,11 @@ pub fn setup_with_default(filter: &str) { replace_logger(logger); } +// Configures logging with the `DEFAULT_FILTER` if RUST_LOG is not set +pub fn setup_with_default_filter() { + setup_with_default(DEFAULT_FILTER); +} + // Configures logging with the default filter "error" if RUST_LOG is not set pub fn setup() { setup_with_default("error"); diff --git a/scripts/run.sh b/scripts/run.sh index 2d8e1ec88ac450..70994c921f47ac 100755 --- a/scripts/run.sh +++ b/scripts/run.sh @@ -37,7 +37,7 @@ $ok || { exit 1 } -export RUST_LOG=${RUST_LOG:-solana=info,solana_runtime::message_processor=debug} # if RUST_LOG is unset, default to info +export RUST_LOG=${RUST_LOG:-solana=info,agave=info,solana_runtime::message_processor=debug} # if RUST_LOG is unset, default to info export RUST_BACKTRACE=1 dataDir=$PWD/config/"$(basename "$0" .sh)" ledgerDir=$PWD/config/ledger diff --git a/transaction-dos/src/main.rs b/transaction-dos/src/main.rs index 94fecf5e6d5f73..dedbcdab27ef79 100644 --- a/transaction-dos/src/main.rs +++ b/transaction-dos/src/main.rs @@ -426,7 +426,7 @@ fn run_transactions_dos( } fn main() { - solana_logger::setup_with_default("solana=info"); + solana_logger::setup_with_default_filter(); let matches = App::new(crate_name!()) .about(crate_description!()) .version(solana_version::version!()) diff --git a/validator/src/lib.rs b/validator/src/lib.rs index e1b9df96b9b03e..9ed2aeab6470a3 100644 --- a/validator/src/lib.rs +++ b/validator/src/lib.rs @@ -41,10 +41,9 @@ pub fn redirect_stderr_to_file(logfile: Option) -> Option env::set_var("RUST_BACKTRACE", "1") } - let filter = "solana=info"; match logfile { None => { - solana_logger::setup_with_default(filter); + solana_logger::setup_with_default_filter(); None } Some(logfile) => { @@ -58,7 +57,7 @@ pub fn redirect_stderr_to_file(logfile: Option) -> Option exit(1); }); - solana_logger::setup_with_default(filter); + solana_logger::setup_with_default_filter(); redirect_stderr(&logfile); Some( std::thread::Builder::new() diff --git a/watchtower/src/main.rs b/watchtower/src/main.rs index 341b7903c0a33e..11dd70e27285dc 100644 --- a/watchtower/src/main.rs +++ b/watchtower/src/main.rs @@ -246,7 +246,7 @@ fn get_cluster_info( } fn main() -> Result<(), Box> { - solana_logger::setup_with_default("solana=info"); + solana_logger::setup_with_default_filter(); solana_metrics::set_panic_hook("watchtower", /*version:*/ None); let config = get_config();