Add a log macro at debug level
It can be useful to debug rustup's operation.  This comit adds a debug
macro using BRIGHT_BLUE which only displays if RUSTUP_DEBUG is in the
environment
@@ -16,6 +16,10 @@ macro_rules! verbose {
( $ ( $ arg : tt ) * ) => ( $crate::log::verbose_fmt ( format_args ! ( $ ( $ arg ) * ) ) )
}
+macro_rules! debug {
+ ( $ ( $ arg : tt ) * ) => ( $crate::log::debug_fmt ( format_args ! ( $ ( $ arg ) * ) ) )
+}
+
pub fn warn_fmt(args: fmt::Arguments) {
let mut t = term2::stderr();
let _ = t.fg(term2::color::BRIGHT_YELLOW);
@@ -54,3 +58,15 @@ pub fn verbose_fmt(args: fmt::Arguments) {
let _ = t.write_fmt(args);
let _ = write!(t, "\n");
}
+
+pub fn debug_fmt(args: fmt::Arguments) {
+ if std::env::var("RUSTUP_DEBUG").is_ok() {
+ let mut t = term2::stderr();
+ let _ = t.fg(term2::color::BRIGHT_BLUE);
+ let _ = t.attr(term2::Attr::Bold);
+ let _ = write!(t, "verbose: ");
+ let _ = t.reset();
+ let _ = t.write_fmt(args);
+ let _ = write!(t, "\n");
+ }
+}
