diff --git a/bin/vault-admin/src/main.rs b/bin/vault-admin/src/main.rs index db6d6eb..f37bc8e 100644 --- a/bin/vault-admin/src/main.rs +++ b/bin/vault-admin/src/main.rs @@ -110,7 +110,10 @@ struct Arguments { async fn main() -> Result<()> { let args = Arguments::parse(); - setup_logging(&args.log_level)?; + tracing::subscriber::set_global_default(setup_logging( + env!("CARGO_CRATE_NAME"), + &args.log_level, + )?)?; info!("Quote verified! Connection secure!"); diff --git a/bin/verify-era-proof-attestation/src/main.rs b/bin/verify-era-proof-attestation/src/main.rs index 137db06..b1388aa 100644 --- a/bin/verify-era-proof-attestation/src/main.rs +++ b/bin/verify-era-proof-attestation/src/main.rs @@ -26,7 +26,11 @@ use zksync_basic_types::L1BatchNumber; #[tokio::main] async fn main() -> Result<()> { let args = Arguments::parse(); - setup_logging(&args.log_level)?; + tracing::subscriber::set_global_default(setup_logging( + env!("CARGO_CRATE_NAME"), + &args.log_level, + )?)?; + validate_arguments(&args)?; let (stop_sender, stop_receiver) = watch::channel(false); let mut process_handle = tokio::spawn(verify_batches_proofs(stop_receiver, args)); diff --git a/crates/teepot/src/log/mod.rs b/crates/teepot/src/log/mod.rs index e91b7fa..d0fd107 100644 --- a/crates/teepot/src/log/mod.rs +++ b/crates/teepot/src/log/mod.rs @@ -5,9 +5,11 @@ use anyhow::Context; use tracing::level_filters::LevelFilter; +use tracing::Subscriber; use tracing_log::LogTracer; +use tracing_subscriber::fmt::format::FmtSpan; use tracing_subscriber::Registry; -use tracing_subscriber::{fmt, prelude::*, EnvFilter}; +use tracing_subscriber::{prelude::*, EnvFilter}; /// A log level parser for clap, with "off", "error", "warn", "info", "debug", "trace" as valid values #[derive(Clone)] @@ -42,7 +44,10 @@ impl clap::builder::TypedValueParser for LogLevelParser { } /// Setup standard logging and loglevel for the current crate and the `teepot` crate. -pub fn setup_logging(log_level: &LevelFilter) -> anyhow::Result<()> { +pub fn setup_logging( + crate_name: &str, + log_level: &LevelFilter, +) -> anyhow::Result { LogTracer::init().context("Failed to set logger")?; let filter = EnvFilter::builder() .try_from_env() @@ -50,14 +55,17 @@ pub fn setup_logging(log_level: &LevelFilter) -> anyhow::Result<()> { LevelFilter::OFF => EnvFilter::new("off"), _ => EnvFilter::new(format!( "warn,{crate_name}={log_level},teepot={log_level}", - crate_name = env!("CARGO_CRATE_NAME"), log_level = log_level )), }); - let subscriber = Registry::default() - .with(filter) - .with(fmt::layer().with_writer(std::io::stderr)); - tracing::subscriber::set_global_default(subscriber)?; - Ok(()) + let fmt_layer = tracing_subscriber::fmt::layer() + .with_span_events(FmtSpan::NEW | FmtSpan::CLOSE) + .with_file(false) + .with_line_number(false) + .with_writer(std::io::stderr); + + let subscriber = Registry::default().with(filter).with(fmt_layer); + + Ok(subscriber) }