Skip to content

Commit

Permalink
Adding env_logger
Browse files Browse the repository at this point in the history
  • Loading branch information
simsekgokhan committed Jan 19, 2024
1 parent 9300823 commit 10e9fb9
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
24 changes: 24 additions & 0 deletions src/env_logger.rs
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 10e9fb9

Please sign in to comment.