Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ensure log crate output is shown with tracing #2477

Merged
merged 2 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions bin/katana/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 3 additions & 0 deletions bin/katana/src/cli/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
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;

Expand Down Expand Up @@ -250,6 +251,8 @@
katana_core=trace,blockifier=off,jsonrpsee_server=off,\
hyper=off,messaging=debug,node=error";

LogTracer::init()?;

Check warning on line 254 in bin/katana/src/cli/node.rs

View check run for this annotation

Codecov / codecov/patch

bin/katana/src/cli/node.rs#L254

Added line #L254 was not covered by tests

let builder = fmt::Subscriber::builder().with_env_filter(
EnvFilter::try_from_default_env().or(EnvFilter::try_new(DEFAULT_LOG_FILTER))?,
);
Expand Down
1 change: 1 addition & 0 deletions bin/saya/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 4 additions & 1 deletion bin/saya/src/args/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use starknet::signers::SigningKey;
use starknet_account::StarknetAccountOptions;
use tracing::Subscriber;
use tracing_log::LogTracer;
use tracing_subscriber::{fmt, EnvFilter};
use url::Url;

Expand Down Expand Up @@ -74,7 +75,9 @@

impl SayaArgs {
pub fn init_logging(&self) -> Result<(), Box<dyn std::error::Error>> {
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()?;

Check warning on line 80 in bin/saya/src/args/mod.rs

View check run for this annotation

Codecov / codecov/patch

bin/saya/src/args/mod.rs#L78-L80

Added lines #L78 - L80 were not covered by tests

let builder = fmt::Subscriber::builder().with_env_filter(
EnvFilter::try_from_default_env().or(EnvFilter::try_new(DEFAULT_LOG_FILTER))?,
Expand Down
2 changes: 1 addition & 1 deletion bin/sozo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
18 changes: 10 additions & 8 deletions bin/sozo/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -53,13 +52,16 @@ impl SozoArgs {
}

pub fn init_logging(&self) -> Result<(), Box<dyn std::error::Error>> {
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<dyn Subscriber + Send + Sync> = 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)?)
}
Expand Down
Loading