Common log init function
This commit is contained in:
parent
53f9bff95c
commit
3aa00586e3
@ -13,24 +13,8 @@ pub enum ChainEra {
|
||||
Homestead,
|
||||
}
|
||||
|
||||
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
|
||||
};
|
||||
}
|
||||
|
||||
pub fn json_chain_test(json_data: &[u8], era: ChainEra) -> Vec<String> {
|
||||
let _ = LOG_DUMMY.deref();
|
||||
init_log();
|
||||
let json = Json::from_str(::std::str::from_utf8(json_data).unwrap()).expect("Json is invalid");
|
||||
let mut failed = Vec::new();
|
||||
|
||||
|
@ -43,8 +43,6 @@ extern crate tiny_keccak;
|
||||
#[macro_use]
|
||||
extern crate heapsize;
|
||||
#[macro_use]
|
||||
extern crate log;
|
||||
#[macro_use]
|
||||
extern crate lazy_static;
|
||||
#[macro_use]
|
||||
extern crate itertools;
|
||||
@ -56,6 +54,8 @@ extern crate arrayvec;
|
||||
extern crate elastic_array;
|
||||
extern crate crossbeam;
|
||||
extern crate serde;
|
||||
#[macro_use]
|
||||
extern crate log as rlog;
|
||||
|
||||
/// TODO [Gav Wood] Please document me
|
||||
pub mod standard;
|
||||
@ -98,6 +98,7 @@ pub mod semantic_version;
|
||||
pub mod io;
|
||||
/// TODO [Gav Wood] Please document me
|
||||
pub mod network;
|
||||
pub mod log;
|
||||
|
||||
pub use common::*;
|
||||
pub use misc::*;
|
||||
@ -118,3 +119,4 @@ pub use squeeze::*;
|
||||
pub use semantic_version::*;
|
||||
pub use network::*;
|
||||
pub use io::*;
|
||||
pub use log::*;
|
||||
|
26
util/src/log.rs
Normal file
26
util/src/log.rs
Normal file
@ -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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user