@@ -22,6 +22,7 @@ use secp256k1::{SecretKey, PublicKey};
22
22
use std:: time:: { SystemTime , UNIX_EPOCH } ;
23
23
use std:: sync:: { Arc , Mutex } ;
24
24
use std:: { mem} ;
25
+ use std:: collections:: HashMap ;
25
26
26
27
pub struct TestVecWriter ( pub Vec < u8 > ) ;
27
28
impl Writer for TestVecWriter {
@@ -190,6 +191,7 @@ impl msgs::RoutingMessageHandler for TestRoutingMessageHandler {
190
191
pub struct TestLogger {
191
192
level : Level ,
192
193
id : String ,
194
+ pub lines : Mutex < HashMap < ( String , String ) , usize > > ,
193
195
}
194
196
195
197
impl TestLogger {
@@ -200,6 +202,7 @@ impl TestLogger {
200
202
TestLogger {
201
203
level : Level :: Trace ,
202
204
id,
205
+ lines : Mutex :: new ( HashMap :: new ( ) )
203
206
}
204
207
}
205
208
pub fn enable ( & mut self , level : Level ) {
@@ -209,10 +212,16 @@ impl TestLogger {
209
212
210
213
impl Logger for TestLogger {
211
214
fn log ( & self , record : & Record ) {
215
+ * self . lines . lock ( ) . unwrap ( ) . entry ( ( record. module_path . to_string ( ) , format ! ( "{}" , record. args) ) ) . or_insert ( 0 ) += 1 ;
212
216
if self . level >= record. level {
213
217
println ! ( "{:<5} {} [{} : {}, {}] {}" , record. level. to_string( ) , self . id, record. module_path, record. file, record. line, record. args) ;
214
218
}
215
219
}
220
+
221
+ fn assert_log ( & self , module : String , line : String , count : usize ) {
222
+ let log_entries = self . lines . lock ( ) . unwrap ( ) ;
223
+ assert_eq ! ( log_entries. get( & ( module, line) ) , Some ( & count) ) ;
224
+ }
216
225
}
217
226
218
227
pub struct TestKeysInterface {
0 commit comments