Refactor fuzzing to be a C-callable library plus rust binaries
[rust-lightning] / fuzz / src / utils / test_logger.rs
diff --git a/fuzz/src/utils/test_logger.rs b/fuzz/src/utils/test_logger.rs
new file mode 100644 (file)
index 0000000..097d001
--- /dev/null
@@ -0,0 +1,23 @@
+use lightning::util::logger::{Logger, Record};
+pub struct TestLogger {
+       #[cfg(test)]
+       id: String,
+}
+
+impl TestLogger {
+       pub fn new(_id: String) -> TestLogger {
+               TestLogger {
+                       #[cfg(test)]
+                       id: _id
+               }
+       }
+}
+
+impl Logger for TestLogger {
+       fn log(&self, record: &Record) {
+               #[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);
+       }
+}