diff --git a/Cargo.toml b/Cargo.toml index 562482a..f9500d5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,9 @@ edition = "2021" [dependencies] bincode = "1" chrono = "0.4.31" +env_logger = "0.10.2" futures = "0.3" +log = "0.4" # for env_logger rayon = "1.7.0" reqwest = { version = "0.11" } serde = "1" diff --git a/src/env_logger.rs b/src/env_logger.rs new file mode 100644 index 0000000..6ea76f4 --- /dev/null +++ b/src/env_logger.rs @@ -0,0 +1,24 @@ +use log::{debug, error, info}; + +// env_logger +// https://docs.rs/env_logger/latest/env_logger/# + +#[test] +fn ex1() { + env_logger::init(); + // By order of importance: + error!("this is printed by default"); + info!("this is info {}", "message"); + debug!("this is a debug {}", "message"); +} + // $ RUST_LOG=error cargo r ... + // [2023-11-09T02:12:24Z ERROR main] this is printed by default + + // $ RUST_LOG=info cargo r ... + // [2023-11-09T02:12:24Z ERROR main] this is printed by default + // [2023-11-09T02:12:24Z INFO main] this is info + + // $ RUST_LOG=debug cargo r ... + // [2023-11-09T02:12:24Z ERROR main] this is printed by default + // [2023-11-09T02:12:24Z INFO main] this is info + // [2023-11-09T02:12:24Z DEBUG main] this is a debug message \ No newline at end of file diff --git a/src/lib.rs b/src/lib.rs index 7d364ba..3b0161d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -15,6 +15,7 @@ mod concurrency; mod const_fn; mod drop_aka_dtor; mod r#enum; +mod env_logger; mod error_handling; mod func_ptr; mod int_overflow;