diff --git a/Cargo.lock b/Cargo.lock index d19911a3fe8..1c52f17cb2a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4861,7 +4861,6 @@ dependencies = [ "dialoguer", "dirs", "distance", - "fern", "flate2", "hex", "http_req", diff --git a/lib/cli/Cargo.toml b/lib/cli/Cargo.toml index 16bb64cc449..fa6a0875e9f 100644 --- a/lib/cli/Cargo.toml +++ b/lib/cli/Cargo.toml @@ -54,8 +54,6 @@ distance = "0.4" # For the inspect subcommand bytesize = "1.0" cfg-if = "1.0" -# For debug feature -fern = { version = "0.6", features = ["colored"], optional = true } tempfile = "3.4.0" http_req = { version="^0.8", default-features = false, features = ["rust-tls"] } reqwest = { version = "^0.11", default-features = false, features = ["rustls-tls", "json", "multipart"] } @@ -166,7 +164,7 @@ llvm = [ "wasmer-compiler-llvm", "compiler", ] -debug = ["fern", "wasmer-wasi/logging"] +debug = ["tracing", "wasmer-wasi/logging"] disable-all-logging = ["wasmer-wasi/disable-all-logging", "log/release_max_level_off"] headless = [] headless-minimal = ["headless", "disable-all-logging", "wasi"] diff --git a/lib/cli/src/logging.rs b/lib/cli/src/logging.rs index 887c6a7eb20..bfa6148bcfa 100644 --- a/lib/cli/src/logging.rs +++ b/lib/cli/src/logging.rs @@ -1,7 +1,7 @@ //! Logging functions for the debug feature. /// Subroutine to instantiate the loggers -#[cfg(feature = "tracing")] +#[cfg(any(feature = "tracing", feature = "debug"))] pub fn set_up_logging(verbose: u8) -> Result<(), String> { use tracing_subscriber::prelude::*; use tracing_subscriber::{fmt, EnvFilter}; @@ -26,73 +26,3 @@ pub fn set_up_logging(verbose: u8) -> Result<(), String> { Ok(()) } - -/// Subroutine to instantiate the loggers -#[deprecated("please use the tracing feature instead")] -#[cfg(not(feature = "tracing"))] -pub fn set_up_logging(verbose: u8) -> Result<(), String> { - use crate::utils::wasmer_should_print_color; - use anyhow::Result; - use fern::colors::{Color, ColoredLevelConfig}; - use std::time; - - /// The debug level - pub type DebugLevel = log::LevelFilter; - - let colors_line = ColoredLevelConfig::new() - .error(Color::Red) - .warn(Color::Yellow) - .trace(Color::BrightBlack); - let should_color = wasmer_should_print_color(); - - let colors_level = colors_line.info(Color::Green); - let level = match verbose { - 1 => DebugLevel::Debug, - _ => DebugLevel::Trace, - }; - let dispatch = fern::Dispatch::new() - .level(level) - .chain({ - let base = if should_color { - fern::Dispatch::new().format(move |out, message, record| { - let time = time::SystemTime::now().duration_since(time::UNIX_EPOCH).expect("Can't get time"); - out.finish(format_args!( - "{color_line}[{seconds}.{millis} {level} {target}{color_line}]{ansi_close} {message}", - color_line = format_args!( - "\x1B[{}m", - colors_line.get_color(&record.level()).to_fg_str() - ), - seconds = time.as_secs(), - millis = time.subsec_millis(), - level = colors_level.color(record.level()), - target = record.target(), - ansi_close = "\x1B[0m", - message = message, - )); - }) - } else { - // default formatter without color - fern::Dispatch::new().format(move |out, message, record| { - let time = time::SystemTime::now().duration_since(time::UNIX_EPOCH).expect("Can't get time"); - out.finish(format_args!( - "[{seconds}.{millis} {level} {target}] {message}", - seconds = time.as_secs(), - millis = time.subsec_millis(), - level = record.level(), - target = record.target(), - message = message, - )); - }) - }; - - base - .filter(|metadata| { - metadata.target().starts_with("wasmer") - }) - .chain(std::io::stdout()) - }); - - dispatch.apply().map_err(|e| format!("{}", e))?; - - Ok(()) -}