January 2019
Beginner to intermediate
554 pages
13h 31m
English
env_logger is a simple logging implementation that allows you to control logs to stdout or stderr through the RUST_LOG environment variable. The values of this environment variable are comma-separated logger strings that correspond to module names and log levels. To demonstrate env_logger, we'll create a new binary crate by running cargo new env_logger_demo and specifying dependencies for log, env_logger, and our user_auth library, which we created in the previous section. Here's our Cargo.toml file:
# env_logger_demo/Cargo.toml[dependencies]env_logger = "0.6.0"user_auth = { path = "../user_auth" }log = { version = "0.4.6", features = ["release_max_level_error", "max_level_trace"] }
Here's our main.rs file:
// env_logger_demo/src/main.rs ...
Read now
Unlock full access