Skip to content

Commit 9ee6b26

Browse files
committed
Unify test logger output
Now that we have Display implemented on Record, the various test logger implementations can make use of that.
1 parent 25b440e commit 9ee6b26

File tree

5 files changed

+10
-36
lines changed

5 files changed

+10
-36
lines changed

fuzz/src/full_stack.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1608,14 +1608,7 @@ mod tests {
16081608
.unwrap()
16091609
.entry((record.module_path.to_string(), format!("{}", record.args)))
16101610
.or_insert(0) += 1;
1611-
println!(
1612-
"{:<5} [{} : {}, {}] {}",
1613-
record.level.to_string(),
1614-
record.module_path,
1615-
record.file,
1616-
record.line,
1617-
record.args
1618-
);
1611+
println!("{}", record);
16191612
}
16201613
}
16211614

fuzz/src/onion_message.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,11 @@ impl MessageRouter for TestMessageRouter {
102102
fn find_path(
103103
&self, _sender: PublicKey, _peers: Vec<PublicKey>, destination: Destination,
104104
) -> Result<OnionMessagePath, ()> {
105-
Ok(OnionMessagePath { intermediate_nodes: vec![], destination, first_node_addresses: vec![] })
105+
Ok(OnionMessagePath {
106+
intermediate_nodes: vec![],
107+
destination,
108+
first_node_addresses: vec![],
109+
})
106110
}
107111

108112
fn create_blinded_paths<T: secp256k1::Signing + secp256k1::Verification>(
@@ -328,14 +332,7 @@ mod tests {
328332
let mut lines_lock = self.lines.lock().unwrap();
329333
let key = (record.module_path.to_string(), format!("{}", record.args));
330334
*lines_lock.entry(key).or_insert(0) += 1;
331-
println!(
332-
"{:<5} [{} : {}, {}] {}",
333-
record.level.to_string(),
334-
record.module_path,
335-
record.file,
336-
record.line,
337-
record.args
338-
);
335+
println!("{}", record);
339336
}
340337
}
341338

fuzz/src/utils/test_logger.rs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,6 @@ impl<'a, Out: Output> Write for LockedWriteAdapter<'a, Out> {
5959

6060
impl<Out: Output> Logger for TestLogger<Out> {
6161
fn log(&self, record: Record) {
62-
write!(
63-
LockedWriteAdapter(&self.out),
64-
"{:<5} {} [{} : {}] {}\n",
65-
record.level.to_string(),
66-
self.id,
67-
record.module_path,
68-
record.line,
69-
record.args
70-
)
71-
.unwrap();
62+
write!(LockedWriteAdapter(&self.out), "{:<6} {}", self.id, record).unwrap();
7263
}
7364
}

lightning-dns-resolver/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ mod test {
192192
}
193193
impl Logger for TestLogger {
194194
fn log(&self, record: lightning::util::logger::Record) {
195-
eprintln!("{}: {}", self.node, record.args);
195+
eprintln!("{:<8} {}", self.node, record);
196196
}
197197
}
198198
impl Deref for TestLogger {

lightning-net-tokio/src/lib.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -629,14 +629,7 @@ mod tests {
629629
pub struct TestLogger();
630630
impl lightning::util::logger::Logger for TestLogger {
631631
fn log(&self, record: lightning::util::logger::Record) {
632-
println!(
633-
"{:<5} [{} : {}, {}] {}",
634-
record.level.to_string(),
635-
record.module_path,
636-
record.file,
637-
record.line,
638-
record.args
639-
);
632+
println!("{}", record);
640633
}
641634
}
642635

0 commit comments

Comments
 (0)