embassy-usb-logger

Crates

git

Versions

default

Flavors

Crate embassy_usb_logger

Source
Expand description

§embassy-usb-logger

USB implementation of the log crate. This logger can be used by any device that implements embassy-usb. When running, it will output all logging done through the log facade to the USB serial peripheral.

§Usage

Add the following embassy task to your application. The Driver type is different depending on which HAL you use.

#[embassy_executor::task]
async fn logger_task(driver: Driver<'static, USB>) {
   embassy_usb_logger::run!(1024, log::LevelFilter::Info, driver);
}

Macros§

run
Initialize and run the USB serial logger, never returns.
with_class
Initialize the USB serial logger from a serial class and return the future to run it.
with_custom_style
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.

Structs§

DummyHandler
Use this Handler if you don’t wish to use any handler
LoggerState
The logger state containing buffers that must live as long as the USB peripheral.
UsbLogger
The logger handle, which contains a pipe with configurable size for buffering log messages.
Writer
A writer that writes to the USB logger buffer.

Constants§

MAX_PACKET_SIZE
The packet size used in the usb logger, to be used with create_future_from_class

Traits§

ReceiverHandler
A trait that can be implemented and then passed to the