Fix logger (#72)

This commit is contained in:
vms 2021-03-01 11:09:41 +03:00 committed by GitHub
parent 7356f03fa9
commit 2744d86c7f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 112 additions and 160 deletions

211
Cargo.lock generated
View File

@ -45,7 +45,7 @@ checksum = "afddf7f520a80dbf76e6f50a35bca42a2331ef227a28b3b6dc5c2e2338d114b1"
name = "aqua-interpreter-interface" name = "aqua-interpreter-interface"
version = "0.3.1" version = "0.3.1"
dependencies = [ dependencies = [
"fluence", "fluence 0.4.2",
"fluence-it-types", "fluence-it-types",
"serde", "serde",
] ]
@ -56,7 +56,7 @@ version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f4c49b8a5fe1336a9c6981be09cb13706c7d9083e48588d692120b5080a13278" checksum = "f4c49b8a5fe1336a9c6981be09cb13706c7d9083e48588d692120b5080a13278"
dependencies = [ dependencies = [
"fluence", "fluence 0.2.18",
"fluence-it-types", "fluence-it-types",
"serde", "serde",
] ]
@ -65,7 +65,7 @@ dependencies = [
name = "aqua-test-module" name = "aqua-test-module"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"fluence", "fluence 0.4.2",
] ]
[[package]] [[package]]
@ -73,7 +73,7 @@ name = "aqua-test-utils"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"aquamarine-vm", "aquamarine-vm",
"fluence", "fluence 0.4.2",
"serde_json", "serde_json",
] ]
@ -81,7 +81,7 @@ dependencies = [
name = "aquamarine" name = "aquamarine"
version = "0.7.0" version = "0.7.0"
dependencies = [ dependencies = [
"fluence", "fluence 0.4.2",
"interpreter-lib", "interpreter-lib",
"log", "log",
"serde", "serde",
@ -91,12 +91,12 @@ dependencies = [
[[package]] [[package]]
name = "aquamarine-vm" name = "aquamarine-vm"
version = "0.3.1" version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "170e51ff427660612f237ce4d3e4fd28218f080e97fcfc23ebd587bdac3379fa" checksum = "93ba3f6550b35f2b8aca0abb9de64744c0d50a8bc58ed14509e8456a74a2efa8"
dependencies = [ dependencies = [
"aqua-interpreter-interface 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "aqua-interpreter-interface 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"fluence-faas 0.2.0", "fluence-faas",
"log", "log",
"maplit", "maplit",
"parking_lot 0.11.1", "parking_lot 0.11.1",
@ -252,9 +252,9 @@ dependencies = [
[[package]] [[package]]
name = "bumpalo" name = "bumpalo"
version = "3.6.0" version = "3.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "099e596ef14349721d9016f6b80dd3419ea1bf289ab9b44df8e4dfd3a005d5d9" checksum = "63396b8a4b9de3f4fdfb320ab6080762242f66a8ef174c49d8e19b674db4cdbe"
[[package]] [[package]]
name = "byte-tools" name = "byte-tools"
@ -279,9 +279,9 @@ dependencies = [
[[package]] [[package]]
name = "cc" name = "cc"
version = "1.0.66" version = "1.0.67"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4c0496836a84f8d0495758516b8621a622beb77c0fed418570e50764093ced48" checksum = "e3c69b077ad434294d3ce9f1f6143a2a4b89a8a2d54ef813d85003a4fd1137fd"
[[package]] [[package]]
name = "cfg-if" name = "cfg-if"
@ -340,12 +340,6 @@ dependencies = [
"unicode-width", "unicode-width",
] ]
[[package]]
name = "const_fn"
version = "0.4.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "28b9d6de7f49e22cf97ad17fc4036ece69300032f45f78f30b4a4482cdc3f4a6"
[[package]] [[package]]
name = "constant_time_eq" name = "constant_time_eq"
version = "0.1.5" version = "0.1.5"
@ -471,12 +465,11 @@ dependencies = [
[[package]] [[package]]
name = "crossbeam-epoch" name = "crossbeam-epoch"
version = "0.9.1" version = "0.9.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a1aaa739f95311c2c7887a76863f500026092fb1dce0161dab577e559ef3569d" checksum = "2584f639eb95fea8c798496315b297cf81b9b58b6d30ab066a75455333cf4b12"
dependencies = [ dependencies = [
"cfg-if 1.0.0", "cfg-if 1.0.0",
"const_fn",
"crossbeam-utils", "crossbeam-utils",
"lazy_static", "lazy_static",
"memoffset", "memoffset",
@ -485,9 +478,9 @@ dependencies = [
[[package]] [[package]]
name = "crossbeam-utils" name = "crossbeam-utils"
version = "0.8.1" version = "0.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "02d96d1e189ef58269ebe5b97953da3274d83a93af647c2ddd6f9dab28cedb8d" checksum = "e7e9d99fa91428effe99c5c6d4634cdeba32b8cf784fc428a2a687f61a952c49"
dependencies = [ dependencies = [
"autocfg", "autocfg",
"cfg-if 1.0.0", "cfg-if 1.0.0",
@ -655,39 +648,16 @@ checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed"
[[package]] [[package]]
name = "fce" name = "fce"
version = "0.1.30" version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9deb5e4f0e1533694ffbfd3644b8047ae41e8098165cdf5934a60b71f82e30c9" checksum = "c75a27d84a4a5622cc3a30fcd02418cccce10e6964af80fe99564d3d8731ec19"
dependencies = [ dependencies = [
"anyhow",
"boolinator", "boolinator",
"fce-utils", "fce-utils",
"fce-wit-generator 0.1.30", "fce-wit-generator",
"fce-wit-interfaces", "fce-wit-interfaces",
"fce-wit-parser 0.1.29", "fce-wit-parser",
"log",
"multi-map",
"multimap",
"parity-wasm",
"pwasm-utils",
"safe-transmute",
"serde",
"wasmer-interface-types-fl",
"wasmer-runtime-core-fl",
"wasmer-runtime-fl",
"wasmer-wasi-fl",
]
[[package]]
name = "fce"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "54e680149a26e9b74a140a143d624c1fe83f6a9d28daf8a12b2bdba261343a71"
dependencies = [
"boolinator",
"fce-utils",
"fce-wit-generator 0.2.0",
"fce-wit-interfaces",
"fce-wit-parser 0.2.0",
"log", "log",
"multi-map", "multi-map",
"multimap", "multimap",
@ -695,6 +665,7 @@ dependencies = [
"pwasm-utils", "pwasm-utils",
"safe-transmute", "safe-transmute",
"serde", "serde",
"thiserror",
"wasmer-interface-types-fl", "wasmer-interface-types-fl",
"wasmer-runtime-core-fl", "wasmer-runtime-core-fl",
"wasmer-runtime-fl", "wasmer-runtime-fl",
@ -707,29 +678,14 @@ version = "0.1.29"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b7a516882dccba04f0034e288c1aa5f06ce9da2711a7ce984ceebac8117e185e" checksum = "b7a516882dccba04f0034e288c1aa5f06ce9da2711a7ce984ceebac8117e185e"
[[package]]
name = "fce-wit-generator"
version = "0.1.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4e19c183d232092a59aeaa4f22212699b3da2acf0bcc5329a9de2a7bb7aa9f87"
dependencies = [
"fce-wit-parser 0.1.29",
"fluence-sdk-wit",
"once_cell",
"serde",
"serde_json",
"walrus",
"wasmer-interface-types-fl",
]
[[package]] [[package]]
name = "fce-wit-generator" name = "fce-wit-generator"
version = "0.2.0" version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1eca715cf832f99fd59dae4f639e4437e5ac92a4470e0879624049f6cb1a3910" checksum = "1eca715cf832f99fd59dae4f639e4437e5ac92a4470e0879624049f6cb1a3910"
dependencies = [ dependencies = [
"fce-wit-parser 0.2.0", "fce-wit-parser",
"fluence-sdk-wit", "fluence-sdk-wit 0.2.18",
"once_cell", "once_cell",
"serde", "serde",
"serde_json", "serde_json",
@ -747,20 +703,6 @@ dependencies = [
"wasmer-interface-types-fl", "wasmer-interface-types-fl",
] ]
[[package]]
name = "fce-wit-parser"
version = "0.1.29"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a3c96db901280554168870de60ca609dea7bc7bdce9aae58d6c294faf812d43c"
dependencies = [
"anyhow",
"fce-wit-interfaces",
"serde",
"walrus",
"wasmer-interface-types-fl",
"wasmer-runtime-core-fl",
]
[[package]] [[package]]
name = "fce-wit-parser" name = "fce-wit-parser"
version = "0.2.0" version = "0.2.0"
@ -787,17 +729,27 @@ version = "0.2.18"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "27d9a5e4292d7bbd809a0e968e3c3aacac91cbc5acab3e26ee1e1d726f0aab24" checksum = "27d9a5e4292d7bbd809a0e968e3c3aacac91cbc5acab3e26ee1e1d726f0aab24"
dependencies = [ dependencies = [
"fluence-sdk-macro", "fluence-sdk-macro 0.2.18",
"fluence-sdk-main", "fluence-sdk-main 0.2.18",
]
[[package]]
name = "fluence"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "31068fe4873478f9c59f01230dc6f23d504d8c11a36d6b6c51693b20c6d2570e"
dependencies = [
"fluence-sdk-macro 0.4.2",
"fluence-sdk-main 0.4.2",
] ]
[[package]] [[package]]
name = "fluence-app-service" name = "fluence-app-service"
version = "0.1.30" version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2fb49d32cad551606cc6ef324b93b0079e7f7f8a54be15176a314098028195cb" checksum = "f64788737ce00700efe6a1e45f7462d3bdba6765891d76b81c806f250f8062f0"
dependencies = [ dependencies = [
"fluence-faas 0.1.30", "fluence-faas",
"log", "log",
"maplit", "maplit",
"serde", "serde",
@ -809,37 +761,14 @@ dependencies = [
[[package]] [[package]]
name = "fluence-faas" name = "fluence-faas"
version = "0.1.30" version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a74511b8a8fc16e3cb3749631824b90f89cecb742cbbaf4e467a0873e34a5a53" checksum = "00434a1581cfdb781b889f1c11e2b8b6ad160a717021e62054be2e9796c1d13d"
dependencies = [ dependencies = [
"cmd_lib", "cmd_lib",
"fce 0.1.30", "fce",
"fce-utils", "fce-utils",
"fluence-sdk-main", "fluence-sdk-main 0.4.2",
"itertools 0.9.0",
"log",
"safe-transmute",
"serde",
"serde_derive",
"serde_json",
"toml",
"wasmer-interface-types-fl",
"wasmer-runtime-core-fl",
"wasmer-runtime-fl",
"wasmer-wasi-fl",
]
[[package]]
name = "fluence-faas"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f0696945762ee0d5ed97537bdd0fa1c71957fc23794074ae035d428e90bedae5"
dependencies = [
"cmd_lib",
"fce 0.2.0",
"fce-utils",
"fluence-sdk-main",
"itertools 0.9.0", "itertools 0.9.0",
"log", "log",
"safe-transmute", "safe-transmute",
@ -872,7 +801,16 @@ version = "0.2.18"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ea1a7c75a617f827d1ba9a17b4d84e1565ab239915c63f5a85c41f89a9f1d4ba" checksum = "ea1a7c75a617f827d1ba9a17b4d84e1565ab239915c63f5a85c41f89a9f1d4ba"
dependencies = [ dependencies = [
"fluence-sdk-wit", "fluence-sdk-wit 0.2.18",
]
[[package]]
name = "fluence-sdk-macro"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "76ce80dc2d7c3db828fb31b95e75c372fde7a9a25dfa2b0d9beac07379b890a6"
dependencies = [
"fluence-sdk-wit 0.4.2",
] ]
[[package]] [[package]]
@ -881,7 +819,18 @@ version = "0.2.18"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6edcc983f9517c1b6bf9f851ef27f2894a3159aaa4a2fb6c9deb2ae8ecb603fa" checksum = "6edcc983f9517c1b6bf9f851ef27f2894a3159aaa4a2fb6c9deb2ae8ecb603fa"
dependencies = [ dependencies = [
"fluence-sdk-macro", "fluence-sdk-macro 0.2.18",
"log",
"serde",
]
[[package]]
name = "fluence-sdk-main"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "29cce53288e08ed86ebe36c64d8eb641a95e1d0f7f75da969b29e16ab0d7d406"
dependencies = [
"fluence-sdk-macro 0.4.2",
"log", "log",
"serde", "serde",
] ]
@ -900,6 +849,20 @@ dependencies = [
"uuid", "uuid",
] ]
[[package]]
name = "fluence-sdk-wit"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "56d835812bab8fb6f261b9e37355b9bf0a28a16123580145ce0fe44ef4363144"
dependencies = [
"proc-macro2",
"quote",
"serde",
"serde_json",
"syn",
"uuid",
]
[[package]] [[package]]
name = "fstrings" name = "fstrings"
version = "0.2.3" version = "0.2.3"
@ -1082,7 +1045,7 @@ dependencies = [
"criterion", "criterion",
"csv", "csv",
"env_logger", "env_logger",
"fluence", "fluence 0.4.2",
"fluence-app-service", "fluence-app-service",
"jsonpath_lib-fl", "jsonpath_lib-fl",
"log", "log",
@ -1357,9 +1320,9 @@ dependencies = [
[[package]] [[package]]
name = "once_cell" name = "once_cell"
version = "1.5.2" version = "1.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "13bd41f508810a131401606d54ac32a467c97172d74ba7662562ebba5ad07fa0" checksum = "10acf907b94fc1b1a152d08ef97e7759650268cf986bf127f387e602b02c7e5a"
[[package]] [[package]]
name = "oorandom" name = "oorandom"
@ -1498,7 +1461,7 @@ dependencies = [
name = "polyplets" name = "polyplets"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"fluence", "fluence 0.4.2",
"serde", "serde",
] ]
@ -1877,18 +1840,18 @@ dependencies = [
[[package]] [[package]]
name = "thiserror" name = "thiserror"
version = "1.0.23" version = "1.0.24"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "76cc616c6abf8c8928e2fdcc0dbfab37175edd8fb49a4641066ad1364fdab146" checksum = "e0f4a65597094d4483ddaed134f409b2cb7c1beccf25201a9f73c719254fa98e"
dependencies = [ dependencies = [
"thiserror-impl", "thiserror-impl",
] ]
[[package]] [[package]]
name = "thiserror-impl" name = "thiserror-impl"
version = "1.0.23" version = "1.0.24"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9be73a2caec27583d0046ef3796c3794f868a5bc813db689eed00c7631275cd1" checksum = "7765189610d8241a44529806d6fd1f2e0a08734313a35d5b3a556f92b381f3c0"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",

View File

@ -11,7 +11,7 @@ name = "aqua_interpreter_interface"
path = "src/lib.rs" path = "src/lib.rs"
[dependencies] [dependencies]
fluence = "0.2.18" fluence = { version = "0.4.2", features = ["logger"] }
fluence-it-types = "0.1.0" fluence-it-types = "0.1.0"
serde = "=1.0.118" serde = "=1.0.118"

View File

@ -10,5 +10,5 @@ name = "polyplets"
path = "src/lib.rs" path = "src/lib.rs"
[dependencies] [dependencies]
fluence = { version = "0.2.18", features = ["logger"] } fluence = { version = "0.4.2", features = ["logger"] }
serde = { version = "=1.0.118", features = ["rc"] } serde = { version = "=1.0.118", features = ["rc"] }

View File

@ -10,4 +10,4 @@ name = "aqua_test_module"
path = "src/main.rs" path = "src/main.rs"
[dependencies] [dependencies]
fluence = { version = "0.2.18", features = ["logger"] } fluence = { version = "0.4.2", features = ["logger"] }

View File

@ -10,6 +10,6 @@ name = "aqua_test_utils"
path = "src/lib.rs" path = "src/lib.rs"
[dependencies] [dependencies]
fluence = { version = "0.2.18", features = ["logger"] } fluence = { version = "0.4.2", features = ["logger"] }
aquamarine-vm = { version = "0.3.1", features = ["raw-aquamarine-vm-api"] } aquamarine-vm = { version = "0.5.1", features = ["raw-aquamarine-vm-api"] }
serde_json = "1.0.56" serde_json = "1.0.56"

View File

@ -10,7 +10,7 @@ path = "src/lib.rs"
[dependencies] [dependencies]
air-parser = { path = "../crates/air-parser" } air-parser = { path = "../crates/air-parser" }
fluence = { version = "0.2.18", features = ["logger"] } fluence = { version = "0.4.2", features = ["logger"] }
polyplets = { path = "../crates/polyplets" } polyplets = { path = "../crates/polyplets" }
aqua-interpreter-interface = { path = "../crates/interpreter-interface" } aqua-interpreter-interface = { path = "../crates/interpreter-interface" }
@ -28,7 +28,7 @@ wasm-bindgen = "=0.2.65"
[dev_dependencies] [dev_dependencies]
aqua-test-utils = { path = "../crates/test-utils" } aqua-test-utils = { path = "../crates/test-utils" }
fluence-app-service = "0.1.29" fluence-app-service = "0.5.1"
criterion = "0.3.3" criterion = "0.3.3"
csv = "1.1.5" csv = "1.1.5"

View File

@ -80,7 +80,7 @@ fn set_last_error<'i>(
macro_rules! log_join { macro_rules! log_join {
($($args:tt)*) => { ($($args:tt)*) => {
log::trace!(target: crate::log_targets::JOIN_BEHAVIOUR, $($args)*) log::info!(target: crate::log_targets::JOIN_BEHAVIOUR, $($args)*)
} }
} }

View File

@ -198,6 +198,7 @@ fn fold_json_path() {
use fluence_app_service::AppService; use fluence_app_service::AppService;
use fluence_app_service::AppServiceConfig; use fluence_app_service::AppServiceConfig;
use fluence_app_service::FaaSConfig; use fluence_app_service::FaaSConfig;
use fluence_app_service::ModuleDescriptor;
use interpreter_lib::execution_trace::CallResult; use interpreter_lib::execution_trace::CallResult;
use interpreter_lib::execution_trace::ExecutedState; use interpreter_lib::execution_trace::ExecutedState;
@ -208,9 +209,15 @@ fn construct_service_config(module_name: impl Into<String>) -> AppServiceConfig
let module_name = module_name.into(); let module_name = module_name.into();
let module_path = format!("./tests/security_tetraplets/{}/target/wasm32-wasi/debug/", module_name); let module_path = format!("./tests/security_tetraplets/{}/target/wasm32-wasi/debug/", module_name);
let module_descriptor = ModuleDescriptor {
file_name: module_name.clone() + ".wasm",
import_name: module_name,
..<_>::default()
};
let faas_config = FaaSConfig { let faas_config = FaaSConfig {
modules_dir: Some(PathBuf::from(module_path)), modules_dir: Some(PathBuf::from(module_path)),
modules_config: vec![(module_name, <_>::default())], modules_config: vec![module_descriptor],
default_modules_config: None, default_modules_config: None,
}; };

View File

@ -10,6 +10,6 @@ path = "src/main.rs"
[dependencies] [dependencies]
interpreter-lib = { path = "../../../../interpreter-lib" } interpreter-lib = { path = "../../../../interpreter-lib" }
fluence = { version = "0.2.18", features = ["logger"] } fluence = { version = "0.4.2", features = ["logger"] }
[workspace] [workspace]

View File

@ -10,6 +10,6 @@ path = "src/main.rs"
[dependencies] [dependencies]
interpreter-lib = { path = "../../../../interpreter-lib" } interpreter-lib = { path = "../../../../interpreter-lib" }
fluence = { version = "0.2.18", features = ["logger"] } fluence = { version = "0.4.2", features = ["logger"] }
[workspace] [workspace]

View File

@ -16,7 +16,7 @@ path = "src/fce.rs"
[dependencies] [dependencies]
interpreter-lib = { path = "../interpreter-lib" } interpreter-lib = { path = "../interpreter-lib" }
fluence = { version = "0.2.18", features = ["logger"] } fluence = { version = "0.4.2", features = ["logger"] }
# Keep 0.2.65 until this is resolved https://github.com/rustwasm/wasm-pack/issues/886 # Keep 0.2.65 until this is resolved https://github.com/rustwasm/wasm-pack/issues/886
wasm-bindgen = "=0.2.65" wasm-bindgen = "=0.2.65"

View File

@ -32,11 +32,6 @@ mod logger;
use fluence::fce; use fluence::fce;
use interpreter_lib::execute_aqua; use interpreter_lib::execute_aqua;
use interpreter_lib::InterpreterOutcome; use interpreter_lib::InterpreterOutcome;
use logger::DEFAULT_LOG_LEVEL;
use log::Level as LogLevel;
const WASM_LOG_ENV_NAME: &str = "WASM_LOG";
pub fn main() { pub fn main() {
logger::init_logger(); logger::init_logger();
@ -44,9 +39,6 @@ pub fn main() {
#[fce] #[fce]
pub fn invoke(init_peer_id: String, aqua: String, prev_data: Vec<u8>, data: Vec<u8>) -> InterpreterOutcome { pub fn invoke(init_peer_id: String, aqua: String, prev_data: Vec<u8>, data: Vec<u8>) -> InterpreterOutcome {
let log_level = get_log_level();
log::set_max_level(log_level.to_level_filter());
execute_aqua(init_peer_id, aqua, prev_data, data) execute_aqua(init_peer_id, aqua, prev_data, data)
} }
@ -54,12 +46,3 @@ pub fn invoke(init_peer_id: String, aqua: String, prev_data: Vec<u8>, data: Vec<
pub fn ast(script: String) -> String { pub fn ast(script: String) -> String {
ast::ast(script) ast::ast(script)
} }
fn get_log_level() -> LogLevel {
use std::str::FromStr;
match std::env::var(WASM_LOG_ENV_NAME) {
Ok(log_level_str) => LogLevel::from_str(&log_level_str).unwrap_or(DEFAULT_LOG_LEVEL),
Err(_) => DEFAULT_LOG_LEVEL,
}
}

View File

@ -16,14 +16,11 @@
use interpreter_lib::log_targets::TARGET_MAP; use interpreter_lib::log_targets::TARGET_MAP;
use log::Level as LogLevel;
pub const DEFAULT_LOG_LEVEL: LogLevel = LogLevel::Info;
pub fn init_logger() { pub fn init_logger() {
let target_map = TARGET_MAP.iter().cloned().collect(); let target_map = TARGET_MAP.iter().cloned().collect();
fluence::WasmLoggerBuilder::new() fluence::WasmLoggerBuilder::new()
.with_target_map(target_map) .with_target_map(target_map)
.filter("jsonpath_lib", log::LevelFilter::Info)
.build() .build()
.unwrap(); .unwrap();
} }

View File

@ -30,10 +30,12 @@ mod ast;
mod logger; mod logger;
use interpreter_lib::execute_aqua; use interpreter_lib::execute_aqua;
use logger::DEFAULT_LOG_LEVEL;
use log::LevelFilter;
use wasm_bindgen::prelude::*; use wasm_bindgen::prelude::*;
pub const DEFAULT_LOG_LEVEL: LevelFilter = LevelFilter::Trace;
#[wasm_bindgen(start)] #[wasm_bindgen(start)]
pub fn main() { pub fn main() {
logger::init_logger(); logger::init_logger();
@ -43,8 +45,8 @@ pub fn main() {
pub fn invoke(init_peer_id: String, aqua: String, prev_data: Vec<u8>, data: Vec<u8>, log_level: &str) -> String { pub fn invoke(init_peer_id: String, aqua: String, prev_data: Vec<u8>, data: Vec<u8>, log_level: &str) -> String {
use std::str::FromStr; use std::str::FromStr;
let log_level = log::Level::from_str(log_level).unwrap_or(DEFAULT_LOG_LEVEL); let log_level = log::LevelFilter::from_str(log_level).unwrap_or(DEFAULT_LOG_LEVEL);
log::set_max_level(log_level.to_level_filter()); log::set_max_level(log_level);
let outcome = execute_aqua(init_peer_id, aqua, prev_data, data); let outcome = execute_aqua(init_peer_id, aqua, prev_data, data);
serde_json::to_string(&outcome).expect("Cannot parse InterpreterOutcome") serde_json::to_string(&outcome).expect("Cannot parse InterpreterOutcome")