rust-lightning/fuzz/fuzz_targets/utils/test_logger.rs
Antoine Riard 0029f04fce Logging interface
Implement error, warn, info, debug and trace macros, internally calling
an instance of Logger, and passing it to every main structures
Build-time or client-side filtering.
Issue #54
2018-08-17 00:01:15 +00:00

23 lines
499 B
Rust

use lightning::util::logger::{Logger, Level, Record};
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) {
#[cfg(any(test, not(feature = "fuzztarget")))]
println!("{:<5} [{} : {}, {}] {}", record.level.to_string(), record.module_path, record.file, record.line, record.args);
}
}