Simple Logger new
In order to use the simple_logger crate we need to add that and log to Cargo.toml
[package]
name = "simple_logger_new"
version = "0.1.0"
edition = "2021"
[dependencies]
log = "0.4.22"
simple_logger = "5.0.0"
fn main() { simple_logger::SimpleLogger::new().init().unwrap(); log::trace!("This is a sample trace."); log::debug!("This is a sample debug."); log::info!("This is a sample info."); log::warn!("This is a sample warn."); log::error!("This is a sample error."); }
By default it print out all the log levels.
2024-08-04T12:13:57.055Z TRACE [simple_logger_new] This is a sample trace.
2024-08-04T12:13:57.055Z DEBUG [simple_logger_new] This is a sample debug.
2024-08-04T12:13:57.055Z INFO [simple_logger_new] This is a sample info.
2024-08-04T12:13:57.055Z WARN [simple_logger_new] This is a sample warn.
2024-08-04T12:13:57.055Z ERROR [simple_logger_new] This is a sample error.