From 150e9f0f8cad07372389b13c132f8dfefca5ea1b Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Mon, 10 Dec 2018 21:30:55 -0500 Subject: [PATCH] Include the node id in ChannelManager test logs --- src/ln/channelmanager.rs | 4 ++-- src/util/test_utils.rs | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/ln/channelmanager.rs b/src/ln/channelmanager.rs index d36945874..137a2a3e7 100644 --- a/src/ln/channelmanager.rs +++ b/src/ln/channelmanager.rs @@ -4303,12 +4303,12 @@ mod tests { let mut nodes = Vec::new(); let mut rng = thread_rng(); let secp_ctx = Secp256k1::new(); - let logger: Arc = Arc::new(test_utils::TestLogger::new()); let chan_count = Rc::new(RefCell::new(0)); let payment_count = Rc::new(RefCell::new(0)); - for _ in 0..node_count { + for i in 0..node_count { + let logger: Arc = Arc::new(test_utils::TestLogger::with_id(format!("node {}", i))); let feeest = Arc::new(test_utils::TestFeeEstimator { sat_per_kw: 253 }); let chain_monitor = Arc::new(chaininterface::ChainWatchInterfaceUtil::new(Network::Testnet, Arc::clone(&logger))); let tx_broadcaster = Arc::new(test_utils::TestBroadcaster{txn_broadcasted: Mutex::new(Vec::new())}); diff --git a/src/util/test_utils.rs b/src/util/test_utils.rs index 4cd4f4406..3acb0d02e 100644 --- a/src/util/test_utils.rs +++ b/src/util/test_utils.rs @@ -183,12 +183,17 @@ impl msgs::RoutingMessageHandler for TestRoutingMessageHandler { pub struct TestLogger { level: Level, + id: String, } impl TestLogger { pub fn new() -> TestLogger { + Self::with_id("".to_owned()) + } + pub fn with_id(id: String) -> TestLogger { TestLogger { level: Level::Trace, + id, } } pub fn enable(&mut self, level: Level) { @@ -199,7 +204,7 @@ impl TestLogger { impl Logger for TestLogger { fn log(&self, record: &Record) { if self.level >= record.level { - println!("{:<5} [{} : {}, {}] {}", record.level.to_string(), record.module_path, record.file, record.line, record.args); + println!("{:<5} {} [{} : {}, {}] {}", record.level.to_string(), self.id, record.module_path, record.file, record.line, record.args); } } } -- 2.39.5