From fbf3b0766e04c85392328ace119c4e527f4c1ef1 Mon Sep 17 00:00:00 2001 From: Marek Kaput Date: Fri, 19 Jan 2024 11:16:16 +0100 Subject: [PATCH] Synchronize `tracing` color preference with `scarb-ui` stderr one (#1068) Signed-off-by: Marek Kaput --- scarb/src/bin/scarb/main.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/scarb/src/bin/scarb/main.rs b/scarb/src/bin/scarb/main.rs index 4b72ea26b..9e0de2893 100644 --- a/scarb/src/bin/scarb/main.rs +++ b/scarb/src/bin/scarb/main.rs @@ -21,6 +21,9 @@ mod errors; fn main() { let args = ScarbArgs::parse(); + // Pre-create Ui used in logging & error reporting, because we will move `args` to `cli_main`. + let ui = Ui::new(args.ui_verbosity(), args.output_format()); + tracing_subscriber::fmt() .with_writer(std::io::stderr) .with_env_filter( @@ -29,11 +32,9 @@ fn main() { .with_env_var("SCARB_LOG") .from_env_lossy(), ) + .with_ansi(ui.has_colors_enabled_stderr()) .init(); - // Pre-create Ui used in error reporting, because we will move `args` to `cli_main`. - let ui = Ui::new(args.ui_verbosity(), args.output_format()); - if let Err(err) = cli_main(args) { exit_with_error(err, &ui); }