Skip to content

Commit 152b020

Browse files
committed
Log structured channel id
Since most log messages no longer include the channel ID in their text, this commit updates the test logger to output the structured channel ID instead. The ID is truncated for readability.
1 parent 8012704 commit 152b020

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lightning/src/util/test_utils.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1700,7 +1700,9 @@ impl Logger for TestLogger {
17001700
fn log(&self, record: Record) {
17011701
let context =
17021702
format!("{} {} [{}:{}]", self.id, record.level, record.module_path, record.line);
1703-
let s = format!("{:<55} {}", context, record.args);
1703+
let chan_id = record.channel_id.map(|id| format!("{}", id));
1704+
let chan_str = chan_id.as_deref().and_then(|s| s.get(..6)).unwrap_or("");
1705+
let s = format!("{:<55} {:<6} {}", context, chan_str, record.args);
17041706
#[cfg(ldk_bench)]
17051707
{
17061708
// When benchmarking, we don't actually want to print logs, but we do want to format

0 commit comments

Comments
 (0)