Expand description
logger.rs Lightweight, feature-gated logger implementation for embedded environments.
This module provides:
- A
Loggertrait for uniform logging - A
log!macro withdebug_logfeature gating - Multiple logger implementations:
SerialLogger: For serial output (core::fmt::Write)BufferedLogger: Keeps logs in memory (heapless::String)NoopLogger: Discards all log output
When the debug_log feature is disabled, the log! macro expands to nothing,
and all logging calls are removed at compile time.
§Example
use dvcdbg::{log, logger::{Logger, SerialLogger}};
struct DummyWriter(String);
impl core::fmt::Write for DummyWriter {
fn write_str(&mut self, s: &str) -> core::fmt::Result {
self.0.push_str(s);
Ok(())
}
}
let mut dw = DummyWriter(String::new());
let mut logger = SerialLogger::new(&mut dw);
log!(logger, "Hello {}!", "world");Structs§
- Buffered
Logger - Logger that stores messages in a heapless string buffer.
- Noop
Logger - Logger that discards all messages.
- Serial
Logger - Logger that writes directly to any
core::fmt::Writetarget.
Traits§
- Logger
- Common logging interface.