Skip to content

Commit

Permalink
fix(logs): add peer id in run-console log (#2385)
Browse files Browse the repository at this point in the history
* add peer id in run-console log

* fix log
  • Loading branch information
gurinderu committed Sep 20, 2024
1 parent d292cf4 commit 6ec487f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions crates/created-swarm/src/swarm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,7 @@ pub async fn create_swarm_with_runtime<RT: AquaRuntime>(
let thread_pinner = Arc::new(test_utils::pinning::DUMMY);

let node = Node::new(
peer_id,
resolved.clone(),
core_distributor,
thread_pinner,
Expand Down
1 change: 1 addition & 0 deletions nox/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ async fn start_fluence(
.wrap_err("Failed to get default system service distros")?;

let mut node: Box<Node<AVMRunner>> = Node::new(
peer_id,
config,
core_distributor,
thread_pinner,
Expand Down
3 changes: 3 additions & 0 deletions nox/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ async fn setup_listener(

impl<RT: AquaRuntime> Node<RT> {
pub async fn new(
peer_id: PeerId,
config: ResolvedConfig,
core_distributor: Arc<dyn CoreDistributor>,
thread_pinner: Arc<dyn ThreadPinner>,
Expand Down Expand Up @@ -312,6 +313,7 @@ impl<RT: AquaRuntime> Node<RT> {
};

let builtins_config = BuiltinsConfig::new(
peer_id,
services_config,
config.dir_config.services_persistent_dir.clone(),
config.node_config.allowed_effectors.clone(),
Expand Down Expand Up @@ -893,6 +895,7 @@ mod tests {
let thread_pinner = Arc::new(test_utils::pinning::DUMMY);

let mut node: Box<Node<AVMRunner>> = Node::new(
PeerId::random(),
config,
core_distributor,
thread_pinner,
Expand Down
8 changes: 6 additions & 2 deletions particle-builtins/src/builtins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ pub struct Builtins<C> {

#[derive(Debug)]
pub struct BuiltinsConfig {
pub peer_id: PeerId,

pub particle_app_services: ParticleAppServicesConfig,
/// Dir to store .wasm modules and their configs
pub modules_dir: PathBuf,
Expand All @@ -140,6 +142,7 @@ pub struct BuiltinsConfig {

impl BuiltinsConfig {
pub fn new(
peer_id: PeerId,
particle_app_services: ParticleAppServicesConfig,
persistent_dir: PathBuf,
allowed_effectors: HashMap<Hash, HashMap<String, PathBuf>>,
Expand Down Expand Up @@ -193,6 +196,7 @@ impl BuiltinsConfig {
.collect::<_>()
};
Ok(Self {
peer_id,
particle_app_services,
blueprint_dir,
modules_dir,
Expand Down Expand Up @@ -407,10 +411,10 @@ where
let decider = function_args.filter_map(JValue::as_str).any(|s| s.contains("decider"));
if decider {
// if log comes from decider, log it as INFO
log::info!(target: "run-console", "{}", json!(args.function_args));
tracing::info!(target: "run-console", peer_id = self.config.peer_id.to_string(), "{}", json!(args.function_args));
} else {
// log everything else as DEBUG
log::debug!(target: "run-console", "{}", json!(args.function_args));
tracing::debug!(target: "run-console", peer_id = self.config.peer_id.to_string(), "{}", json!(args.function_args));
}
wrap_unit(Ok(()))
}
Expand Down

0 comments on commit 6ec487f

Please sign in to comment.