What changed, and why it matters
This commit is a minor code cleanup in test-only logging code. It replaces several hand-written log formatting blocks with a single shared Display implementation for log records. There is no functional change to production code and no security relevance.
No action required. This is a non-security refactoring commit affecting only test code.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch refactors test logger implementations across fuzz tests, the DNS resolver test module, and the tokio networking test module to use the Display trait now implemented on lightning::util::logger::Record. The changes are purely cosmetic: log output format is slightly adjusted (e.g., alignment/prefix), but no logic, parsing, or runtime behavior changes. One unrelated formatting change in fuzz/src/onion_message.rs rewraps a struct literal across multiple lines with no semantic change.
Changed components
fuzz/src/full_stack.rs (test logger)fuzz/src/onion_message.rs (test logger, plus cosmetic formatting)fuzz/src/utils/test_logger.rs (test logger)lightning-dns-resolver/src/lib.rs (test logger)lightning-net-tokio/src/lib.rs (test logger)Inspect captured patch +10 / −36
diff --git a/fuzz/src/full_stack.rs b/fuzz/src/full_stack.rs
index 97a7487..617050f 100644
--- a/fuzz/src/full_stack.rs
+++ b/fuzz/src/full_stack.rs
@@ -1608,14 +1608,7 @@ mod tests {
.unwrap()
.entry((record.module_path.to_string(), format!("{}", record.args)))
.or_insert(0) += 1;
- println!(
- "{:<5} [{} : {}, {}] {}",
- record.level.to_string(),
- record.module_path,
- record.file,
- record.line,
- record.args
- );
+ println!("{}", record);
}
}
diff --git a/fuzz/src/onion_message.rs b/fuzz/src/onion_message.rs
index 934d748..09634a1 100644
--- a/fuzz/src/onion_message.rs
+++ b/fuzz/src/onion_message.rs
@@ -102,7 +102,11 @@ impl MessageRouter for TestMessageRouter {
fn find_path(
&self, _sender: PublicKey, _peers: Vec<PublicKey>, destination: Destination,
) -> Result<OnionMessagePath, ()> {
- Ok(OnionMessagePath { intermediate_nodes: vec![], destination, first_node_addresses: vec![] })
+ Ok(OnionMessagePath {
+ intermediate_nodes: vec![],
+ destination,
+ first_node_addresses: vec![],
+ })
}
fn create_blinded_paths<T: secp256k1::Signing + secp256k1::Verification>(
@@ -328,14 +332,7 @@ mod tests {
let mut lines_lock = self.lines.lock().unwrap();
let key = (record.module_path.to_string(), format!("{}", record.args));
*lines_lock.entry(key).or_insert(0) += 1;
- println!(
- "{:<5} [{} : {}, {}] {}",
- record.level.to_string(),
- record.module_path,
- record.file,
- record.line,
- record.args
- );
+ println!("{}", record);
}
}
diff --git a/fuzz/src/utils/test_logger.rs b/fuzz/src/utils/test_logger.rs
index 6d9de02..f836987 100644
--- a/fuzz/src/utils/test_logger.rs
+++ b/fuzz/src/utils/test_logger.rs
@@ -59,15 +59,6 @@ impl<'a, Out: Output> Write for LockedWriteAdapter<'a, Out> {
impl<Out: Output> Logger for TestLogger<Out> {
fn log(&self, record: Record) {
- write!(
- LockedWriteAdapter(&self.out),
- "{:<5} {} [{} : {}] {}\n",
- record.level.to_string(),
- self.id,
- record.module_path,
- record.line,
- record.args
- )
- .unwrap();
+ write!(LockedWriteAdapter(&self.out), "{:<6} {}", self.id, record).unwrap();
}
}
diff --git a/lightning-dns-resolver/src/lib.rs b/lightning-dns-resolver/src/lib.rs
index 8d47098..bcf3b6f 100644
--- a/lightning-dns-resolver/src/lib.rs
+++ b/lightning-dns-resolver/src/lib.rs
@@ -192,7 +192,7 @@ mod test {
}
impl Logger for TestLogger {
fn log(&self, record: lightning::util::logger::Record) {
- eprintln!("{}: {}", self.node, record.args);
+ eprintln!("{:<8} {}", self.node, record);
}
}
impl Deref for TestLogger {
diff --git a/lightning-net-tokio/src/lib.rs b/lightning-net-tokio/src/lib.rs
index cf66311..038b251 100644
--- a/lightning-net-tokio/src/lib.rs
+++ b/lightning-net-tokio/src/lib.rs
@@ -629,14 +629,7 @@ mod tests {
pub struct TestLogger();
impl lightning::util::logger::Logger for TestLogger {
fn log(&self, record: lightning::util::logger::Record) {
- println!(
- "{:<5} [{} : {}, {}] {}",
- record.level.to_string(),
- record.module_path,
- record.file,
- record.line,
- record.args
- );
+ println!("{}", record);
}
}
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.