File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change 177
177
//! }
178
178
//! ```
179
179
//!
180
+ //! ## Specifying defaults for environment variables
181
+ //!
182
+ //! `env_logger` can read configuration from environment variables.
183
+ //! If these variables aren't present, the default value to use can be tweaked with the [`Env`] type.
184
+ //! The following example defaults to log `warn` and above if the `RUST_LOG` environment variable
185
+ //! isn't set:
186
+ //!
187
+ //! ```
188
+ //! #[macro_use] extern crate log;
189
+ //! extern crate env_logger;
190
+ //!
191
+ //! use log::Level;
192
+ //!
193
+ //! fn main() {
194
+ //! let env = env_logger::Env::default()
195
+ //! .filter_or(env_logger::DEFAULT_FILTER_ENV, "warn");
196
+ //!
197
+ //! env_logger::Builder::from_env(env).init();
198
+ //! }
199
+ //! ```
200
+ //!
180
201
//! [log-crate-url]: https://docs.rs/log/
181
202
//! [`Builder`]: struct.Builder.html
203
+ //! [`Env`]: struct.Env.html
182
204
183
205
#![ doc( html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png" ,
184
206
html_favicon_url = "http://www.rust-lang.org/favicon.ico" ,
You can’t perform that action at this time.
0 commit comments