From c8119dfebf59f7d028c93ae081162711510586a2 Mon Sep 17 00:00:00 2001 From: Marek Kaput Date: Thu, 18 Jan 2024 12:10:01 +0100 Subject: [PATCH] Synchronize `tracing` color preference with `scarb-ui` stderr one 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); }