Skip log formatting entirely for DevNull output
What changed, and why it matters
This commit is a performance optimization for a test-only fuzzing logger. It skips formatting log messages when the output is a special 'DevNull' sink that discards everything anyway. There is no security relevance: no bug is fixed, no memory safety issue is addressed, and no attacker-controlled behavior is changed.
No security action needed. Treat as a normal performance improvement in test infrastructure.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The change adds a compile-time-resolved TypeId check in TestLogger::log to return early when the generic output type is DevNull. Previously, formatting work (SubstringFormatter, fmt::write, from_utf8) was performed even though the result was discarded. This is purely a reduction of wasted CPU work in fuzz/test code and does not alter observable behavior or fix any vulnerability.
Changed components
fuzz/src/utils/test_logger.rsInspect captured patch +4 / −0
diff --git a/fuzz/src/utils/test_logger.rs b/fuzz/src/utils/test_logger.rs
index 193ccc0..e629a7f 100644
--- a/fuzz/src/utils/test_logger.rs
+++ b/fuzz/src/utils/test_logger.rs
@@ -8,6 +8,7 @@
// licenses.
use lightning::util::logger::{Logger, Record};
+use std::any::TypeId;
use std::io::Write;
use std::sync::{Arc, Mutex};
@@ -66,6 +67,9 @@ impl<'a, Out: Output> Write for LockedWriteAdapter<'a, Out> {
impl<Out: Output> Logger for TestLogger<Out> {
fn log(&self, record: Record) {
+ if TypeId::of::<Out>() == TypeId::of::<DevNull>() {
+ return;
+ }
writeln!(LockedWriteAdapter(&self.out), "{:<6} {}", self.id, record).unwrap();
}
}
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.