Trait Logger

Source
pub trait Logger {
    // Required method
    fn log_fmt(&mut self, args: Arguments<'_>);

    // Provided methods
    fn log_bytes(&mut self, label: &str, bytes: &[u8]) { ... }
    fn log_i2c(&mut self, context: &str, result: Result<(), impl Debug>) { ... }
    fn log_cmd(&mut self, cmd: u8) { ... }
}
Expand description

Common logging interface.

Implementors provide a log_fmt() method for formatted output. Additional helper methods like [log_bytes()], [log_i2c()], and [log_cmd()] are enabled only when the debug_log feature is active.

Required Methods§

Source

fn log_fmt(&mut self, args: Arguments<'_>)

Logs a pre-formatted message.

Provided Methods§

Source

fn log_bytes(&mut self, label: &str, bytes: &[u8])

Logs a byte slice in 0xXX format with a label.

Truncates output with ... if it exceeds the internal buffer.

Source

fn log_i2c(&mut self, context: &str, result: Result<(), impl Debug>)

Logs the result of an I2C transaction with a ✅/❌ marker.

Source

fn log_cmd(&mut self, cmd: u8)

Logs a single command byte in 0xXX format.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl Logger for NoopLogger

Source§

impl<'a, W: Write> Logger for SerialLogger<'a, W>

Source§

impl<const N: usize> Logger for BufferedLogger<N>