X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=src%2Futil%2Ftest_utils.rs;h=b5fbbd5940924483545fb5d11c298658dc75feda;hb=7c24fea4fe8af6ae1b51c5ef6e792113d7830abb;hp=9646754f2d0097f51358cf5be9d86c8519acfcd4;hpb=fe9bb1d97028d1c0c98972809d12e7129d18356d;p=rust-lightning diff --git a/src/util/test_utils.rs b/src/util/test_utils.rs index 9646754f2..b5fbbd594 100644 --- a/src/util/test_utils.rs +++ b/src/util/test_utils.rs @@ -5,6 +5,7 @@ use ln::channelmonitor; use ln::msgs; use ln::msgs::{HandleError}; use util::events; +use util::logger::{Logger, Level, Record}; use bitcoin::blockdata::transaction::Transaction; @@ -145,3 +146,26 @@ impl msgs::RoutingMessageHandler for TestRoutingMessageHandler { } fn handle_htlc_fail_channel_update(&self, _update: &msgs::HTLCFailChannelUpdate) {} } + +pub struct TestLogger { + level: Level, +} + +impl TestLogger { + pub fn new() -> TestLogger { + TestLogger { + level: Level::Off, + } + } + pub fn enable(&mut self, level: Level) { + self.level = level; + } +} + +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); + } + } +}