Make test log lines somewhat more eye-scannable 2023-10-scanable-test-logs
authorMatt Corallo <git@bluematt.me>
Thu, 12 Oct 2023 21:15:49 +0000 (21:15 +0000)
committerMatt Corallo <git@bluematt.me>
Sun, 15 Oct 2023 20:04:35 +0000 (20:04 +0000)
When running tests, our log output should be reasonably readable
by developers, but currently it repeats the module twice (via the
module and file name), and then starts the log line at a variable
location.

Instead, we only print the module and then align the start of the
log lines so that the output is much more scannable.

lightning/src/util/test_utils.rs

index bd66e4cae3e56fa70195a4627bf38451bac37d9c..f89d5a99e37d957beda1095b8b57a208b0d048a9 100644 (file)
@@ -969,8 +969,10 @@ impl Logger for TestLogger {
        fn log(&self, record: &Record) {
                *self.lines.lock().unwrap().entry((record.module_path.to_string(), format!("{}", record.args))).or_insert(0) += 1;
                if record.level >= self.level {
-                       #[cfg(all(not(ldk_bench), feature = "std"))]
-                       println!("{:<5} {} [{} : {}, {}] {}", record.level.to_string(), self.id, record.module_path, record.file, record.line, record.args);
+                       #[cfg(all(not(ldk_bench), feature = "std"))] {
+                               let pfx = format!("{} {} [{}:{}]", self.id, record.level.to_string(), record.module_path, record.line);
+                               println!("{:<55}{}", pfx, record.args);
+                       }
                }
        }
 }