From: Matt Corallo Date: Tue, 11 Dec 2018 02:30:55 +0000 (-0500) Subject: Include the node id in ChannelManager test logs X-Git-Tag: v0.0.12~256^2~2 X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=150e9f0f8cad07372389b13c132f8dfefca5ea1b;p=rust-lightning Include the node id in ChannelManager test logs --- 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); } } }