embassy-usb-logger

Crates

git

Versions

default

Flavors

embassy_usb_logger

Macro with_custom_style

Source
macro_rules! with_custom_style {
    ( $x:expr, $l:expr, $p:ident, $s:expr ) => { ... };
    ( $x:expr, $l:expr, $p:ident, $s:expr, $h:ty ) => { ... };
}
Expand description

Initialize the USB serial logger from a serial class and return the future to run it. This version of the macro allows for a custom style function to be passed in. The custom style function will be called for each log record and is responsible for writing the log message to the buffer.

Arguments specify the buffer size, log level, the serial class and the custom style function, respectively. You can optionally add a RecieverHandler.

§Usage

let log_fut = embassy_usb_logger::with_custom_style!(1024, log::LevelFilter::Info, logger_class, |record, writer| {
    use core::fmt::Write;
    let level = record.level().as_str();
    write!(writer, "[{level}] {}\r\n", record.args()).unwrap();
});

§Safety

This macro should only be invoked only once since it is setting the global logging state of the application.