This repository was archived by the owner on Nov 6, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #263 from ethcore/log
Common log init function
- Loading branch information
Showing
3 changed files
with
31 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
//! Common log helper functions | ||
use std::env; | ||
use rlog::{LogLevelFilter}; | ||
use env_logger::LogBuilder; | ||
|
||
lazy_static! { | ||
static ref LOG_DUMMY: bool = { | ||
let mut builder = LogBuilder::new(); | ||
builder.filter(None, LogLevelFilter::Info); | ||
|
||
if let Ok(log) = env::var("RUST_LOG") { | ||
builder.parse(&log); | ||
} | ||
|
||
if let Ok(_) = builder.init() { | ||
println!("logger initialized"); | ||
} | ||
true | ||
}; | ||
} | ||
|
||
/// Intialize log with default settings | ||
pub fn init_log() { | ||
let _ = *LOG_DUMMY; | ||
} |