Skip to content

Commit

Permalink
Apply verbosity flag to scarb package tracing only
Browse files Browse the repository at this point in the history
  • Loading branch information
maciektr committed Feb 20, 2023
1 parent 86a1b49 commit bd67d10
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion scarb/src/bin/scarb/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use anyhow::Result;
use clap::Parser;
use std::str::FromStr;
use tracing_log::AsTrace;
use tracing_subscriber::filter::Directive;
use tracing_subscriber::EnvFilter;

use args::Args;
Expand All @@ -15,11 +17,16 @@ mod commands;
fn main() {
let args: Args = Args::parse();

let cli_log_level_directive = Directive::from_str(
format!("scarb={}", args.verbose.log_level_filter().as_trace()).as_str(),
)
.expect("Failed to parse log level directive from command line.");

tracing_subscriber::fmt()
.with_writer(std::io::stderr)
.with_env_filter(
EnvFilter::builder()
.with_default_directive(args.verbose.log_level_filter().as_trace().into())
.with_default_directive(cli_log_level_directive)
.with_env_var("SCARB_LOG")
.from_env_lossy(),
)
Expand Down

0 comments on commit bd67d10

Please sign in to comment.