mirror of
https://github.com/matter-labs/teepot.git
synced 2025-07-22 15:34:48 +02:00
feat(logging): centralize logging setup in teepot crate
- Added a new logging module in `teepot` crate. - Removed redundant logging setup code from individual projects. - Updated dependencies and references for logging setup. Signed-off-by: Harald Hoyer <harald@matterlabs.dev>
This commit is contained in:
parent
2ff3b1168d
commit
af3ab51320
7 changed files with 85 additions and 68 deletions
|
@ -8,23 +8,21 @@ mod client;
|
|||
mod proof;
|
||||
mod verification;
|
||||
|
||||
use anyhow::{Context, Result};
|
||||
use crate::verification::{
|
||||
log_quote_verification_summary, verify_attestation_quote, verify_batch_proof,
|
||||
};
|
||||
use anyhow::Result;
|
||||
use args::{Arguments, AttestationPolicyArgs};
|
||||
use clap::Parser;
|
||||
use client::MainNodeClient;
|
||||
use proof::get_proofs;
|
||||
use reqwest::Client;
|
||||
use teepot::log::setup_logging;
|
||||
use tokio::{signal, sync::watch};
|
||||
use tracing::{debug, error, info, trace, warn};
|
||||
use tracing_log::LogTracer;
|
||||
use tracing_subscriber::{filter::LevelFilter, fmt, prelude::*, EnvFilter, Registry};
|
||||
use url::Url;
|
||||
use zksync_basic_types::L1BatchNumber;
|
||||
|
||||
use crate::verification::{
|
||||
log_quote_verification_summary, verify_attestation_quote, verify_batch_proof,
|
||||
};
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<()> {
|
||||
let args = Arguments::parse();
|
||||
|
@ -45,26 +43,6 @@ async fn main() -> Result<()> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn setup_logging(log_level: &LevelFilter) -> Result<()> {
|
||||
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(())
|
||||
}
|
||||
|
||||
fn validate_arguments(args: &Arguments) -> Result<()> {
|
||||
if args.attestation_policy.sgx_mrsigners.is_none()
|
||||
&& args.attestation_policy.sgx_mrenclaves.is_none()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue