From: Matt Corallo Date: Sat, 2 Dec 2023 17:54:09 +0000 (+0000) Subject: Add some missing `WithContext` wrappers in `peer_handler.rs` X-Git-Tag: v0.0.119~23^2~3 X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=ab93d35da26a524b812408c3384ac2f60eaadf27;p=rust-lightning Add some missing `WithContext` wrappers in `peer_handler.rs` df3ab2ee2753e7f9ec02ddf1c8a51db77c50e35d added `WithContext` wrappers in most logs in `peer_handler.rs`, but due to long-term rebasing it missed a few, which we add here. --- diff --git a/lightning/src/ln/peer_handler.rs b/lightning/src/ln/peer_handler.rs index f06177289..282e0a75e 100644 --- a/lightning/src/ln/peer_handler.rs +++ b/lightning/src/ln/peer_handler.rs @@ -1286,8 +1286,10 @@ impl { - match $thing { + ($peer: expr, $thing: expr) => {{ + let res = $thing; + let logger = WithContext::from(&self.logger, peer_node_id.map(|(id, _)| id), None); + match res { Ok(x) => x, Err(e) => { match e.action { @@ -1297,7 +1299,7 @@ impl { @@ -1306,32 +1308,32 @@ impl { - log_given_level!(self.logger, level, "Error handling message{}; ignoring: {}", OptionalFromDebugger(&peer_node_id), e.err); + log_given_level!(logger, level, "Error handling message{}; ignoring: {}", OptionalFromDebugger(&peer_node_id), e.err); continue }, msgs::ErrorAction::IgnoreDuplicateGossip => continue, // Don't even bother logging these msgs::ErrorAction::IgnoreError => { - log_debug!(self.logger, "Error handling message{}; ignoring: {}", OptionalFromDebugger(&peer_node_id), e.err); + log_debug!(logger, "Error handling message{}; ignoring: {}", OptionalFromDebugger(&peer_node_id), e.err); continue; }, msgs::ErrorAction::SendErrorMessage { msg } => { - log_debug!(self.logger, "Error handling message{}; sending error message with: {}", OptionalFromDebugger(&peer_node_id), e.err); + log_debug!(logger, "Error handling message{}; sending error message with: {}", OptionalFromDebugger(&peer_node_id), e.err); self.enqueue_message($peer, &msg); continue; }, msgs::ErrorAction::SendWarningMessage { msg, log_level } => { - log_given_level!(self.logger, log_level, "Error handling message{}; sending warning message with: {}", OptionalFromDebugger(&peer_node_id), e.err); + log_given_level!(logger, log_level, "Error handling message{}; sending warning message with: {}", OptionalFromDebugger(&peer_node_id), e.err); self.enqueue_message($peer, &msg); continue; }, } } } - } + }} } let mut peer_lock = peer_mutex.lock().unwrap(); @@ -2005,25 +2007,29 @@ impl { - log_debug!(self.logger, "Handling SendStfu event in peer_handler for node {} for channel {}", + let logger = WithContext::from(&self.logger, Some(*node_id), Some(msg.channel_id)); + log_debug!(logger, "Handling SendStfu event in peer_handler for node {} for channel {}", log_pubkey!(node_id), &msg.channel_id); self.enqueue_message(&mut *get_peer_for_forwarding!(node_id), msg); } MessageSendEvent::SendSplice { ref node_id, ref msg} => { - log_debug!(self.logger, "Handling SendSplice event in peer_handler for node {} for channel {}", + let logger = WithContext::from(&self.logger, Some(*node_id), Some(msg.channel_id)); + log_debug!(logger, "Handling SendSplice event in peer_handler for node {} for channel {}", log_pubkey!(node_id), &msg.channel_id); self.enqueue_message(&mut *get_peer_for_forwarding!(node_id), msg); } MessageSendEvent::SendSpliceAck { ref node_id, ref msg} => { - log_debug!(self.logger, "Handling SendSpliceAck event in peer_handler for node {} for channel {}", + let logger = WithContext::from(&self.logger, Some(*node_id), Some(msg.channel_id)); + log_debug!(logger, "Handling SendSpliceAck event in peer_handler for node {} for channel {}", log_pubkey!(node_id), &msg.channel_id); self.enqueue_message(&mut *get_peer_for_forwarding!(node_id), msg); } MessageSendEvent::SendSpliceLocked { ref node_id, ref msg} => { - log_debug!(self.logger, "Handling SendSpliceLocked event in peer_handler for node {} for channel {}", + let logger = WithContext::from(&self.logger, Some(*node_id), Some(msg.channel_id)); + log_debug!(logger, "Handling SendSpliceLocked event in peer_handler for node {} for channel {}", log_pubkey!(node_id), &msg.channel_id); self.enqueue_message(&mut *get_peer_for_forwarding!(node_id), msg);