]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Include the node id in ChannelManager test logs
authorMatt Corallo <git@bluematt.me>
Tue, 11 Dec 2018 02:30:55 +0000 (21:30 -0500)
committerMatt Corallo <git@bluematt.me>
Fri, 14 Dec 2018 22:01:12 +0000 (17:01 -0500)
src/ln/channelmanager.rs
src/util/test_utils.rs

index d36945874fa6ce34d70a34e66f0b8a7fdac39092..137a2a3e7e73f316ae9ebcd9adb396a52e3f952e 100644 (file)
@@ -4303,12 +4303,12 @@ mod tests {
                let mut nodes = Vec::new();
                let mut rng = thread_rng();
                let secp_ctx = Secp256k1::new();
-               let logger: Arc<Logger> = 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<Logger> = 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())});
index 4cd4f4406b1cb85a109412832b186c2029ef5d78..3acb0d02e78e2bdec6214dd82b5ea117e341d16d 100644 (file)
@@ -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);
                }
        }
 }