From acf6450d22f4a9e635c98430348299ea924c8b90 Mon Sep 17 00:00:00 2001 From: vms Date: Fri, 30 Oct 2020 16:54:46 +0300 Subject: [PATCH] add logging mask to the AquamarineVM config --- Cargo.lock | 48 +++++++++---------- aquamarine-vm/src/aquamarine_stepper_vm.rs | 4 +- aquamarine-vm/src/config.rs | 3 ++ fluence-faas/src/misc/log_utf8_string_impl.rs | 2 +- fluence-faas/src/raw_toml_config.rs | 4 +- 5 files changed, 33 insertions(+), 28 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ae93f1ff..761d6f29 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -724,15 +724,6 @@ dependencies = [ "serde_json", ] -[[package]] -name = "fluence" -version = "0.2.8" -source = "git+https://github.com/fluencelabs/rust-sdk#8c0a02916519872c3d6073de16c950d10da0b2f4" -dependencies = [ - "fluence-sdk-macro 0.2.8 (git+https://github.com/fluencelabs/rust-sdk)", - "fluence-sdk-main 0.2.8 (git+https://github.com/fluencelabs/rust-sdk)", -] - [[package]] name = "fluence" version = "0.2.8" @@ -743,6 +734,15 @@ dependencies = [ "fluence-sdk-main 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "fluence" +version = "0.2.8" +source = "git+https://github.com/fluencelabs/rust-sdk#8c0a02916519872c3d6073de16c950d10da0b2f4" +dependencies = [ + "fluence-sdk-macro 0.2.8 (git+https://github.com/fluencelabs/rust-sdk)", + "fluence-sdk-main 0.2.8 (git+https://github.com/fluencelabs/rust-sdk)", +] + [[package]] name = "fluence-app-service" version = "0.1.10" @@ -780,14 +780,6 @@ dependencies = [ "wasmer-wasi-fl", ] -[[package]] -name = "fluence-sdk-macro" -version = "0.2.8" -source = "git+https://github.com/fluencelabs/rust-sdk#8c0a02916519872c3d6073de16c950d10da0b2f4" -dependencies = [ - "fluence-sdk-wit 0.2.8 (git+https://github.com/fluencelabs/rust-sdk)", -] - [[package]] name = "fluence-sdk-macro" version = "0.2.8" @@ -798,13 +790,11 @@ dependencies = [ ] [[package]] -name = "fluence-sdk-main" +name = "fluence-sdk-macro" version = "0.2.8" source = "git+https://github.com/fluencelabs/rust-sdk#8c0a02916519872c3d6073de16c950d10da0b2f4" dependencies = [ - "fluence-sdk-macro 0.2.8 (git+https://github.com/fluencelabs/rust-sdk)", - "log", - "serde", + "fluence-sdk-wit 0.2.8 (git+https://github.com/fluencelabs/rust-sdk)", ] [[package]] @@ -819,9 +809,20 @@ dependencies = [ ] [[package]] -name = "fluence-sdk-wit" +name = "fluence-sdk-main" version = "0.2.8" source = "git+https://github.com/fluencelabs/rust-sdk#8c0a02916519872c3d6073de16c950d10da0b2f4" +dependencies = [ + "fluence-sdk-macro 0.2.8 (git+https://github.com/fluencelabs/rust-sdk)", + "log", + "serde", +] + +[[package]] +name = "fluence-sdk-wit" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "560baf91197ded38a99a5c94ff366a3dd971ebf33f5d987ecce31d3dedf86d17" dependencies = [ "proc-macro2", "quote", @@ -834,8 +835,7 @@ dependencies = [ [[package]] name = "fluence-sdk-wit" version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "560baf91197ded38a99a5c94ff366a3dd971ebf33f5d987ecce31d3dedf86d17" +source = "git+https://github.com/fluencelabs/rust-sdk#8c0a02916519872c3d6073de16c950d10da0b2f4" dependencies = [ "proc-macro2", "quote", diff --git a/aquamarine-vm/src/aquamarine_stepper_vm.rs b/aquamarine-vm/src/aquamarine_stepper_vm.rs index fbe886ee..e87115e8 100644 --- a/aquamarine-vm/src/aquamarine_stepper_vm.rs +++ b/aquamarine-vm/src/aquamarine_stepper_vm.rs @@ -49,6 +49,7 @@ impl AquamarineVM { config.aquamarine_wasm_path, config.call_service, config.current_peer_id, + config.logging_mask, ); let faas = FluenceFaaS::with_raw_config(faas_config)?; @@ -99,6 +100,7 @@ impl AquamarineVM { aquamarine_wasm_path: PathBuf, call_service: HostImportDescriptor, current_peer_id: String, + logging_mask: i64, ) -> FaaSConfig { use maplit::hashmap; @@ -114,7 +116,7 @@ impl AquamarineVM { logger_enabled: true, host_imports, wasi: None, - logging_mask: i64::max_value(), + logging_mask, } }; diff --git a/aquamarine-vm/src/config.rs b/aquamarine-vm/src/config.rs index 610e2c5f..d7b1f098 100644 --- a/aquamarine-vm/src/config.rs +++ b/aquamarine-vm/src/config.rs @@ -31,4 +31,7 @@ pub struct AquamarineVMConfig { /// Path to a folder contains prev data. /// AquamarineVM uses it to store data obtained after stepper execution, and load it as a prev_data by particle_id. pub particle_data_store: PathBuf, + + /// Mask used to filter logs, for details see `log_utf8_string` in fluence-faas. + pub logging_mask: i64, } diff --git a/fluence-faas/src/misc/log_utf8_string_impl.rs b/fluence-faas/src/misc/log_utf8_string_impl.rs index 2b545531..5299d826 100644 --- a/fluence-faas/src/misc/log_utf8_string_impl.rs +++ b/fluence-faas/src/misc/log_utf8_string_impl.rs @@ -20,7 +20,7 @@ use wasmer_core::memory::ptr::{Array, WasmPtr}; pub(super) fn log_utf8_string_closure( logging_mask: i64, module: String, -) -> impl for<'a> Fn(&'a mut Ctx, i32, i64, i32, i32) { +) -> impl Fn(&mut Ctx, i32, i64, i32, i32) { move |ctx, level, target, msg_offset, msg_size| { if target == 0 || target & logging_mask != 0 { log_utf8_string(&module, ctx, level, msg_offset, msg_size) diff --git a/fluence-faas/src/raw_toml_config.rs b/fluence-faas/src/raw_toml_config.rs index 4e977360..5cd8ee9f 100644 --- a/fluence-faas/src/raw_toml_config.rs +++ b/fluence-faas/src/raw_toml_config.rs @@ -36,7 +36,7 @@ modules_dir = "wasm/artifacts/wasm_modules" mem_pages_count = 100 logger_enabled = true - [module.imports] + [module.mounted_binaries] mysql = "/usr/bin/mysql" ipfs = "/usr/local/bin/ipfs" @@ -49,7 +49,7 @@ modules_dir = "wasm/artifacts/wasm_modules" mem_pages_count = 100 logger_enabled = true - [default.imports] + [default.mounted_binaries] mysql = "/usr/bin/mysql" ipfs = "/usr/local/bin/ipfs"