From 7f5bbe7cb4f98dafd6847794857cb60ec76f9993 Mon Sep 17 00:00:00 2001 From: glihm Date: Tue, 24 Sep 2024 10:11:03 -0400 Subject: [PATCH] fix: ensure log crate is taken in account by tracing --- Cargo.lock | 2 ++ Cargo.toml | 3 ++- bin/katana/Cargo.toml | 1 + bin/katana/src/cli/node.rs | 3 +++ bin/saya/Cargo.toml | 1 + bin/saya/src/args/mod.rs | 5 ++++- bin/sozo/Cargo.toml | 2 +- bin/sozo/src/args.rs | 18 ++++++++++-------- 8 files changed, 24 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5611c8de0e..5958975d2a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7851,6 +7851,7 @@ dependencies = [ "shellexpand", "tokio", "tracing", + "tracing-log 0.1.4", "tracing-subscriber", "url", ] @@ -12097,6 +12098,7 @@ dependencies = [ "starknet-crypto 0.7.2", "tokio", "tracing", + "tracing-log 0.1.4", "tracing-subscriber", "url", ] diff --git a/Cargo.toml b/Cargo.toml index 4b4fdf930a..65d9f26f89 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -200,7 +200,8 @@ tokio = { version = "1.39.2", features = [ "full" ] } toml = "0.8" tower = "0.4.13" tower-http = "0.4.4" -tracing = "0.1.34" +tracing = { version = "0.1.38", features = [ "log" ], default-features = false } +tracing-log = "0.1.3" tracing-subscriber = { version = "0.3.16", features = [ "env-filter", "json" ] } url = { version = "2.4.0", features = [ "serde" ] } walkdir = "2.5.0" diff --git a/bin/katana/Cargo.toml b/bin/katana/Cargo.toml index a268dc4aea..82980bee6e 100644 --- a/bin/katana/Cargo.toml +++ b/bin/katana/Cargo.toml @@ -27,6 +27,7 @@ serde_json.workspace = true shellexpand = "3.1.0" tokio.workspace = true tracing.workspace = true +tracing-log.workspace = true tracing-subscriber.workspace = true url.workspace = true diff --git a/bin/katana/src/cli/node.rs b/bin/katana/src/cli/node.rs index f452bcce00..f4b062b4d1 100644 --- a/bin/katana/src/cli/node.rs +++ b/bin/katana/src/cli/node.rs @@ -35,6 +35,7 @@ use katana_primitives::genesis::Genesis; use katana_rpc::config::ServerConfig; use katana_rpc_api::ApiKind; use tracing::{info, Subscriber}; +use tracing_log::LogTracer; use tracing_subscriber::{fmt, EnvFilter}; use url::Url; @@ -250,6 +251,8 @@ impl NodeArgs { katana_core=trace,blockifier=off,jsonrpsee_server=off,\ hyper=off,messaging=debug,node=error"; + LogTracer::init()?; + let builder = fmt::Subscriber::builder().with_env_filter( EnvFilter::try_from_default_env().or(EnvFilter::try_new(DEFAULT_LOG_FILTER))?, ); diff --git a/bin/saya/Cargo.toml b/bin/saya/Cargo.toml index b289b8b211..8ba73958dc 100644 --- a/bin/saya/Cargo.toml +++ b/bin/saya/Cargo.toml @@ -18,6 +18,7 @@ serde_json.workspace = true starknet.workspace = true tokio.workspace = true tracing.workspace = true +tracing-log.workspace = true tracing-subscriber.workspace = true url.workspace = true diff --git a/bin/saya/src/args/mod.rs b/bin/saya/src/args/mod.rs index 594004354b..2d5e8b7453 100644 --- a/bin/saya/src/args/mod.rs +++ b/bin/saya/src/args/mod.rs @@ -12,6 +12,7 @@ use starknet::core::utils::cairo_short_string_to_felt; use starknet::signers::SigningKey; use starknet_account::StarknetAccountOptions; use tracing::Subscriber; +use tracing_log::LogTracer; use tracing_subscriber::{fmt, EnvFilter}; use url::Url; @@ -74,7 +75,9 @@ pub struct SayaArgs { impl SayaArgs { pub fn init_logging(&self) -> Result<(), Box> { - const DEFAULT_LOG_FILTER: &str = "info,saya::core=trace,blockchain=trace,provider=trace"; + const DEFAULT_LOG_FILTER: &str = "info,saya::core=trace,blockchain=off,provider=off"; + + LogTracer::init()?; let builder = fmt::Subscriber::builder().with_env_filter( EnvFilter::try_from_default_env().or(EnvFilter::try_new(DEFAULT_LOG_FILTER))?, diff --git a/bin/sozo/Cargo.toml b/bin/sozo/Cargo.toml index 711d8b26d0..a2833b0e33 100644 --- a/bin/sozo/Cargo.toml +++ b/bin/sozo/Cargo.toml @@ -56,7 +56,7 @@ starknet-crypto.workspace = true thiserror.workspace = true tokio.workspace = true tracing.workspace = true -tracing-log = "0.1.3" +tracing-log.workspace = true tracing-subscriber.workspace = true url.workspace = true diff --git a/bin/sozo/src/args.rs b/bin/sozo/src/args.rs index 57c1c53ac8..4b977fbe0c 100644 --- a/bin/sozo/src/args.rs +++ b/bin/sozo/src/args.rs @@ -5,9 +5,8 @@ use scarb::compiler::Profile; use scarb_ui::Verbosity; use smol_str::SmolStr; use tracing::level_filters::LevelFilter; -use tracing::Subscriber; -use tracing_log::AsTrace; -use tracing_subscriber::{fmt, EnvFilter}; +use tracing_log::{AsTrace, LogTracer}; +use tracing_subscriber::FmtSubscriber; use crate::commands::Commands; use crate::utils::generate_version; @@ -53,13 +52,16 @@ impl SozoArgs { } pub fn init_logging(&self) -> Result<(), Box> { - const DEFAULT_LOG_FILTER: &str = "info,hyper=off,scarb=off"; + const DEFAULT_LOG_FILTER: &str = "info,hyper=off,scarb=off,salsa=off"; - let builder = fmt::Subscriber::builder().with_env_filter( - EnvFilter::try_from_default_env().or(EnvFilter::try_new(DEFAULT_LOG_FILTER))?, - ); + LogTracer::init()?; - let subscriber: Box = Box::new(builder.finish()); + let subscriber = FmtSubscriber::builder() + .with_env_filter( + tracing_subscriber::EnvFilter::try_from_default_env() + .unwrap_or_else(|_| tracing_subscriber::EnvFilter::new(DEFAULT_LOG_FILTER)), + ) + .finish(); Ok(tracing::subscriber::set_global_default(subscriber)?) }