From 6d4a1903fb05efc8f0eaed13650383341680a671 Mon Sep 17 00:00:00 2001 From: FliegendeWurst <2012gdwu+github@posteo.de> Date: Mon, 17 May 2021 18:12:11 +0200 Subject: [PATCH] Fix logging when the progress bar is enabled --- src/cli.rs | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/cli.rs b/src/cli.rs index 96dfc7b..12fc826 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -2,7 +2,10 @@ use std::{path::PathBuf, sync::atomic::{AtomicBool, AtomicUsize}}; -use anyhow::{anyhow, Context, Result}; +#[cfg(feature = "keyring-auth")] +use anyhow::anyhow; +use anyhow::{Context, Result}; +#[cfg(feature = "keyring-auth")] use colored::Colorize as _; use indicatif::ProgressBar; use once_cell::sync::Lazy; @@ -92,37 +95,37 @@ macro_rules! log { macro_rules! info { ($t:tt) => { - println!($t); + log!(0, $t); }; } macro_rules! success { ($t:tt) => { - println!("{}", format!($t).bright_green()); + log!(0, "{}", format!($t).bright_green()); }; } macro_rules! warning { ($e:expr) => { - println!("Warning: {}", format!("{:?}", $e).bright_yellow()); + log!(0, "Warning: {}", format!("{:?}", $e).bright_yellow()); }; ($msg:expr, $e:expr) => { - println!("Warning: {}", format!("{} {:?}", $msg, $e).bright_yellow()); + log!(0, "Warning: {}", format!("{} {:?}", $msg, $e).bright_yellow()); }; ($msg1:expr, $msg2:expr, $e:expr) => { - println!("Warning: {}", format!("{} {} {:?}", $msg1, $msg2, $e).bright_yellow()); + log!(0, "Warning: {}", format!("{} {} {:?}", $msg1, $msg2, $e).bright_yellow()); }; (format => $($e:expr),+) => { - println!("Warning: {}", format!($($e),+).bright_yellow()); + log!(0, "Warning: {}", format!($($e),+).bright_yellow()); }; } macro_rules! error { ($($prefix:expr),+; $e:expr) => { - println!("{}: {}", format!($($prefix),+), format!("{:?}", $e).bright_red()); + log!(0, "{}: {}", format!($($prefix),+), format!("{:?}", $e).bright_red()); }; ($e:expr) => { - println!("Error: {}", format!("{:?}", $e).bright_red()); + log!(0, "Error: {}", format!("{:?}", $e).bright_red()); }; }