Module logger

Source
Expand description

logger.rs Lightweight, feature-gated logger implementation for embedded environments.

This module provides:

  • A Logger trait for uniform logging
  • A log! macro with debug_log feature 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§

BufferedLogger
Logger that stores messages in a heapless string buffer.
NoopLogger
Logger that discards all messages.
SerialLogger
Logger that writes directly to any core::fmt::Write target.

Traits§

Logger
Common logging interface.