mirror of
https://github.com/fluencelabs/aquavm
synced 2024-12-04 23:20:18 +00:00
Set minimal log level during initialization (#114)
This commit is contained in:
parent
93f71908e0
commit
49f3afda4a
@ -16,11 +16,19 @@
|
||||
|
||||
use air::log_targets::TARGET_MAP;
|
||||
|
||||
pub fn init_logger() {
|
||||
use log::LevelFilter;
|
||||
|
||||
pub fn init_logger(default_level: Option<LevelFilter>) {
|
||||
let target_map = TARGET_MAP.iter().cloned().collect();
|
||||
fluence::WasmLoggerBuilder::new()
|
||||
let builder = fluence::WasmLoggerBuilder::new()
|
||||
.with_target_map(target_map)
|
||||
.filter("jsonpath_lib", log::LevelFilter::Info)
|
||||
.build()
|
||||
.unwrap();
|
||||
.filter("jsonpath_lib", log::LevelFilter::Info);
|
||||
|
||||
let builder = if let Some(default_level) = default_level {
|
||||
builder.with_log_level(default_level)
|
||||
} else {
|
||||
builder
|
||||
};
|
||||
|
||||
builder.build().unwrap();
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ use air::InterpreterOutcome;
|
||||
use fluence::marine;
|
||||
|
||||
pub fn main() {
|
||||
logger::init_logger();
|
||||
logger::init_logger(None);
|
||||
}
|
||||
|
||||
#[marine]
|
||||
|
@ -38,7 +38,14 @@ pub const DEFAULT_LOG_LEVEL: LevelFilter = LevelFilter::Trace;
|
||||
|
||||
#[wasm_bindgen(start)]
|
||||
pub fn main() {
|
||||
logger::init_logger();
|
||||
// it's necessary to initialize it with the minimal allowed log level,
|
||||
// because otherwise it's impossible to set less level than used during initialization.
|
||||
const MINIMAL_LOG_LEVEL: LevelFilter = LevelFilter::Trace;
|
||||
logger::init_logger(Some(MINIMAL_LOG_LEVEL));
|
||||
|
||||
// this one is just a guard for possible changes of the invoke function where some log-prone
|
||||
// code could added before the setting max log level from a function parameter.
|
||||
log::set_max_level(LevelFilter::Info);
|
||||
}
|
||||
|
||||
#[wasm_bindgen]
|
||||
|
Loading…
Reference in New Issue
Block a user