Decouple log targets to a separate crate (#152)

This commit is contained in:
Mike Voronov 2021-10-05 16:55:04 +03:00 committed by GitHub
parent adba9e8e65
commit e99c352a95
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
91 changed files with 63 additions and 36 deletions

7
Cargo.lock generated
View File

@ -17,6 +17,7 @@ version = "0.15.0"
dependencies = [ dependencies = [
"air-interpreter-data", "air-interpreter-data",
"air-interpreter-interface", "air-interpreter-interface",
"air-log-targets",
"air-parser", "air-parser",
"air-test-utils", "air-test-utils",
"air-trace-handler", "air-trace-handler",
@ -45,6 +46,7 @@ name = "air-interpreter"
version = "0.15.0" version = "0.15.0"
dependencies = [ dependencies = [
"air", "air",
"air-log-targets",
"log", "log",
"marine-rs-sdk", "marine-rs-sdk",
"serde", "serde",
@ -72,6 +74,10 @@ dependencies = [
"serde_json", "serde_json",
] ]
[[package]]
name = "air-log-targets"
version = "0.1.0"
[[package]] [[package]]
name = "air-parser" name = "air-parser"
version = "0.7.1" version = "0.7.1"
@ -113,6 +119,7 @@ name = "air-trace-handler"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"air-interpreter-data", "air-interpreter-data",
"air-log-targets",
"air-parser", "air-parser",
"log", "log",
"serde_json", "serde_json",

View File

@ -2,15 +2,16 @@
members = [ members = [
"air", "air",
"air-interpreter", "air-interpreter",
"crates/air-parser",
"crates/data-store",
"crates/polyplets",
"crates/interpreter-interface",
"crates/interpreter-data",
"crates/test-module",
"crates/test-utils",
"crates/trace-handler",
"avm/server", "avm/server",
"crates/air-lib/air-parser",
"crates/air-lib/interpreter-data",
"crates/air-lib/interpreter-interface",
"crates/air-lib/log-targets",
"crates/air-lib/polyplets",
"crates/air-lib/test-utils",
"crates/air-lib/trace-handler",
"crates/data-store",
"crates/test-module",
] ]
exclude = [ exclude = [

View File

@ -16,6 +16,7 @@ path = "src/marine.rs"
[dependencies] [dependencies]
air = { path = "../air" } air = { path = "../air" }
air-log-targets = { path = "../crates/air-lib/log-targets" }
marine-rs-sdk = { version = "0.6.11", features = ["logger"] } marine-rs-sdk = { version = "0.6.11", features = ["logger"] }

View File

@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
use air::log_targets::TARGET_MAP; use air_log_targets::TARGET_MAP;
use log::LevelFilter; use log::LevelFilter;

View File

@ -11,12 +11,13 @@ path = "src/lib.rs"
doctest = false doctest = false
[dependencies] [dependencies]
air-parser = { path = "../crates/air-parser" } air-parser = { path = "../crates/air-lib/air-parser" }
air-interpreter-data = { path = "../crates/interpreter-data" } air-interpreter-data = { path = "../crates/air-lib/interpreter-data" }
air-interpreter-interface = { path = "../crates/interpreter-interface" } air-interpreter-interface = { path = "../crates/air-lib/interpreter-interface" }
air-trace-handler = { path = "../crates/trace-handler" } air-log-targets = { path = "../crates/air-lib/log-targets" }
air-trace-handler = { path = "../crates/air-lib/trace-handler" }
polyplets = { path = "../crates/air-lib/polyplets" }
marine-rs-sdk = { version = "0.6.11", features = ["logger"] } marine-rs-sdk = { version = "0.6.11", features = ["logger"] }
polyplets = { path = "../crates/polyplets" }
serde = { version = "1.0.118", features = [ "derive", "rc" ] } serde = { version = "1.0.118", features = [ "derive", "rc" ] }
serde_json = "1.0.61" serde_json = "1.0.61"
@ -33,7 +34,7 @@ strum_macros = "0.21"
wasm-bindgen = "=0.2.65" wasm-bindgen = "=0.2.65"
[dev_dependencies] [dev_dependencies]
air-test-utils = { path = "../crates/test-utils" } air-test-utils = { path = "../crates/air-lib/test-utils" }
fluence-app-service = "0.9.0" fluence-app-service = "0.9.0"
criterion = "0.3.3" criterion = "0.3.3"

View File

@ -144,7 +144,7 @@ impl<'i> ExecutableInstruction<'i> for Instruction<'i> {
#[macro_export] #[macro_export]
macro_rules! log_instruction { macro_rules! log_instruction {
($instr_name:expr, $exec_ctx:expr, $trace_ctx:expr) => { ($instr_name:expr, $exec_ctx:expr, $trace_ctx:expr) => {
log::debug!(target: crate::log_targets::INSTRUCTION, "> {}", stringify!($instr_name)); log::debug!(target: air_log_targets::INSTRUCTION, "> {}", stringify!($instr_name));
let mut variables = String::from(" scalars:"); let mut variables = String::from(" scalars:");
if $exec_ctx.scalars.is_empty() { if $exec_ctx.scalars.is_empty() {
@ -162,25 +162,25 @@ macro_rules! log_instruction {
variables.push_str(&format!("\n {} => {}", key, value.borrow())); variables.push_str(&format!("\n {} => {}", key, value.borrow()));
} }
log::trace!(target: crate::log_targets::DATA_CACHE, "{}", variables); log::trace!(target: air_log_targets::DATA_CACHE, "{}", variables);
log::trace!( log::trace!(
target: crate::log_targets::NEXT_PEER_PKS, target: air_log_targets::NEXT_PEER_PKS,
" next peers pk: {:?}", " next peers pk: {:?}",
$exec_ctx.next_peer_pks $exec_ctx.next_peer_pks
); );
log::trace!( log::trace!(
target: crate::log_targets::SUBTREE_COMPLETE, target: air_log_targets::SUBTREE_COMPLETE,
" subtree complete: {}", " subtree complete: {}",
$exec_ctx.subtree_complete $exec_ctx.subtree_complete
); );
log::trace!( log::trace!(
target: crate::log_targets::SUBTREE_ELEMENTS, target: air_log_targets::SUBTREE_ELEMENTS,
" subtree elements count: {:?}", " subtree elements count: {:?}",
$trace_ctx.subtree_sizes() $trace_ctx.subtree_sizes()
); );
log::debug!( log::debug!(
target: crate::log_targets::NEW_EXECUTED_TRACE, target: air_log_targets::NEW_EXECUTED_TRACE,
" new call executed trace: {:?}", " new call executed trace: {:?}",
$trace_ctx.as_result_trace() $trace_ctx.as_result_trace()
); );

View File

@ -155,7 +155,7 @@ impl ExecutionError {
macro_rules! log_join { macro_rules! log_join {
($($args:tt)*) => { ($($args:tt)*) => {
log::info!(target: crate::log_targets::JOIN_BEHAVIOUR, $($args)*) log::info!(target: air_log_targets::JOIN_BEHAVIOUR, $($args)*)
} }
} }

View File

@ -28,8 +28,6 @@
mod execution_step; mod execution_step;
mod preparation_step; mod preparation_step;
pub mod log_targets;
mod runner; mod runner;
pub use air_interpreter_interface::InterpreterOutcome; pub use air_interpreter_interface::InterpreterOutcome;

View File

@ -16,16 +16,18 @@
mod outcome; mod outcome;
use crate::execution_step::Catchable;
use crate::execution_step::ExecutableInstruction; use crate::execution_step::ExecutableInstruction;
use crate::execution_step::ExecutionCtx; use crate::execution_step::ExecutionCtx;
use crate::execution_step::ExecutionError; use crate::execution_step::ExecutionError;
use crate::execution_step::{Catchable, TraceHandler}; use crate::execution_step::TraceHandler;
use crate::log_targets::RUN_PARAMS;
use crate::preparation_step::prepare; use crate::preparation_step::prepare;
use crate::preparation_step::PreparationDescriptor; use crate::preparation_step::PreparationDescriptor;
use air_interpreter_interface::InterpreterOutcome; use air_interpreter_interface::InterpreterOutcome;
use air_interpreter_interface::RunParameters; use air_interpreter_interface::RunParameters;
use air_log_targets::RUN_PARAMS;
use std::rc::Rc; use std::rc::Rc;
pub fn execute_air( pub fn execute_air(

View File

@ -12,9 +12,9 @@ path = "src/lib.rs"
[dependencies] [dependencies]
fluence-faas = "0.9.0" fluence-faas = "0.9.0"
air-interpreter-interface = { version = "0.7.0", path = "../../crates/interpreter-interface" } air-interpreter-interface = { version = "0.7.0", path = "../../crates/air-lib/interpreter-interface" }
avm-data-store = { version = "0.1.0", path = "../../crates/data-store" } avm-data-store = { version = "0.1.0", path = "../../crates/data-store" }
polyplets = { version = "0.1.2", path = "../../crates/polyplets" } polyplets = { version = "0.1.2", path = "../../crates/air-lib/polyplets" }
eyre = "0.6.5" eyre = "0.6.5"
thiserror = "1.0.29" thiserror = "1.0.29"

View File

@ -0,0 +1,15 @@
[package]
name = "air-log-targets"
version = "0.1.0"
description = "Definition of global consts used for logging"
authors = ["Fluence Labs"]
edition = "2018"
license = "Apache-2.0"
repository = "https://github.com/fluencelabs/air/crates/log-targets"
publish = false
keywords = ["fluence", "air", "webassembly", "programming-language"]
categories = ["wasm"]
[lib]
name = "air_log_targets"
path = "src/lib.rs"

View File

@ -0,0 +1,3 @@
## AIR logger targets
The marine logger allows adjusting not only by a logging level defined in the `log` crate, but also by a component id (or targets in terms of the `log` crate). So, it could be considered as a matrix where each component could have its own logging level. This crate defines several component id that are used by other crates.

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2020 Fluence Labs Limited * Copyright 2021 Fluence Labs Limited
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View File

@ -11,9 +11,9 @@ name = "air_test_utils"
path = "src/lib.rs" path = "src/lib.rs"
[dependencies] [dependencies]
air = { path = "../../../air" }
air-interpreter-interface = { path = "../interpreter-interface" }
avm-server = { path = "../../../avm/server" }
marine-rs-sdk = "0.6.11" marine-rs-sdk = "0.6.11"
avm-server = { path = "../../avm/server" }
air = { path = "../../air" }
air-interpreter-interface = { path = "../../crates/interpreter-interface" }
serde_json = "1.0.61" serde_json = "1.0.61"

View File

@ -16,6 +16,7 @@ path = "src/lib.rs"
[dependencies] [dependencies]
air-interpreter-data = { path = "../interpreter-data" } air-interpreter-data = { path = "../interpreter-data" }
air-log-targets = { path = "../log-targets" }
air-parser = { path = "../air-parser" } air-parser = { path = "../air-parser" }
serde_json = "1.0.68" serde_json = "1.0.68"

View File

@ -1,6 +1,6 @@
## AIR trace handler ## AIR trace handler
This crate contains implementation of the CRDT-based merging data algorithm. It exposes the `TraceHandler` struct that based on the visitor pattern and has public methods that should be called in certain places of AIR instructions execution. Internally `TraceHandler` contains several FSM and each such public methods do state transitioning of one or more these FSMs. Below are state transition sequences for all instructions that caller must follow. This crate contains implementation of the CRDT-based merging data algorithm. It exposes the `TraceHandler` struct that based on the visitor pattern and has public methods that should be called in certain places of AIR instructions execution. Internally `TraceHandler` contains several FSM and each of such public methods does state transitioning of one or more these FSMs. Below are state transition sequences for all instructions that caller must follow.
### Ap instruction ### Ap instruction

View File

@ -68,7 +68,7 @@ impl TraceHandler {
/// state to the result trace. /// state to the result trace.
pub fn meet_call_end(&mut self, call_result: CallResult) { pub fn meet_call_end(&mut self, call_result: CallResult) {
log::trace!( log::trace!(
target: crate::EXECUTED_STATE_CHANGING, target: air_log_targets::EXECUTED_STATE_CHANGING,
" adding new call executed state {:?}", " adding new call executed state {:?}",
call_result call_result
); );

View File

@ -33,8 +33,6 @@ pub use state_automata::SubtreeType;
pub type TraceHandlerResult<T> = std::result::Result<T, TraceHandlerError>; pub type TraceHandlerResult<T> = std::result::Result<T, TraceHandlerError>;
pub const EXECUTED_STATE_CHANGING: &str = "executed_state_changing";
use air_interpreter_data::*; use air_interpreter_data::*;
use data_keeper::DataKeeper; use data_keeper::DataKeeper;
use data_keeper::MergeCtx; use data_keeper::MergeCtx;