Skip to content

Commit fb29935

Browse files
committed
Include the node id in ChannelManager test logs
1 parent 2ee2695 commit fb29935

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/ln/channelmanager.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4303,12 +4303,12 @@ mod tests {
43034303
let mut nodes = Vec::new();
43044304
let mut rng = thread_rng();
43054305
let secp_ctx = Secp256k1::new();
4306-
let logger: Arc<Logger> = Arc::new(test_utils::TestLogger::new());
43074306

43084307
let chan_count = Rc::new(RefCell::new(0));
43094308
let payment_count = Rc::new(RefCell::new(0));
43104309

4311-
for _ in 0..node_count {
4310+
for i in 0..node_count {
4311+
let logger: Arc<Logger> = Arc::new(test_utils::TestLogger::with_id(format!("node {}", i)));
43124312
let feeest = Arc::new(test_utils::TestFeeEstimator { sat_per_kw: 253 });
43134313
let chain_monitor = Arc::new(chaininterface::ChainWatchInterfaceUtil::new(Network::Testnet, Arc::clone(&logger)));
43144314
let tx_broadcaster = Arc::new(test_utils::TestBroadcaster{txn_broadcasted: Mutex::new(Vec::new())});

src/util/test_utils.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,12 +183,17 @@ impl msgs::RoutingMessageHandler for TestRoutingMessageHandler {
183183

184184
pub struct TestLogger {
185185
level: Level,
186+
id: String,
186187
}
187188

188189
impl TestLogger {
189190
pub fn new() -> TestLogger {
191+
Self::with_id("".to_owned())
192+
}
193+
pub fn with_id(id: String) -> TestLogger {
190194
TestLogger {
191195
level: Level::Trace,
196+
id,
192197
}
193198
}
194199
pub fn enable(&mut self, level: Level) {
@@ -199,7 +204,7 @@ impl TestLogger {
199204
impl Logger for TestLogger {
200205
fn log(&self, record: &Record) {
201206
if self.level >= record.level {
202-
println!("{:<5} [{} : {}, {}] {}", record.level.to_string(), record.module_path, record.file, record.line, record.args);
207+
println!("{:<5} {} [{} : {}, {}] {}", record.level.to_string(), self.id, record.module_path, record.file, record.line, record.args);
203208
}
204209
}
205210
}

0 commit comments

Comments
 (0)