Merge pull request #374 from dongcarl/2019-08-channel-open-sanity
[rust-lightning] / fuzz / fuzz_targets / utils / test_logger.rs
index 2ef1196b586af79c82cde6b787098302997de38e..097d001dbb25f80e0049a6c1526c379365a0f49f 100644 (file)
@@ -1,10 +1,23 @@
 use lightning::util::logger::{Logger, Record};
+pub struct TestLogger {
+       #[cfg(test)]
+       id: String,
+}
 
-pub struct TestLogger {}
+impl TestLogger {
+       pub fn new(_id: String) -> TestLogger {
+               TestLogger {
+                       #[cfg(test)]
+                       id: _id
+               }
+       }
+}
 
 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);
+               #[cfg(test)]
+               println!("{:<5} {} [{} : {}, {}] {}", record.level.to_string(), self.id, record.module_path, record.file, record.line, record.args);
+               #[cfg(not(test))]
+               let _ = format!("{}", record.args);
        }
 }