Skip to content

Commit

Permalink
Merge branch 'main' into handle_old_proof_response
Browse files Browse the repository at this point in the history
  • Loading branch information
pbeza authored Nov 28, 2024
2 parents a7951f9 + 6e88e20 commit 78471f5
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 10 deletions.
5 changes: 4 additions & 1 deletion bin/vault-admin/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!");

Expand Down
6 changes: 5 additions & 1 deletion bin/verify-era-proof-attestation/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
24 changes: 16 additions & 8 deletions crates/teepot/src/log/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down Expand Up @@ -42,22 +44,28 @@ 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<impl Subscriber + Send + Sync + 'static> {
LogTracer::init().context("Failed to set logger")?;
let filter = EnvFilter::builder()
.try_from_env()
.unwrap_or(match *log_level {
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)
}

0 comments on commit 78471f5

Please sign in to comment.