pub enum LoggingFrontend {
    Log(LoggingConfig),
    Defmt,
}
Available on crate features rt and usb-logging only.
Expand description

The logging frontend.

LoggingFrontend provides a convenient API for instantiating a USB1 logger. It works with two different logging front-ends, described by the enum values.

When used for USB logging, the implementation registers the USB1 interrupt handler (USB_OTG1). This requires the BSP’s "rt" feature. Registering an interrupt handler may not be appropriate for environments where interrupts are defined and registered elsewhere. If that’s the case, you should directly use logging APIs.

For advanced logging configurations, see logging.

§Example

Register a USB logger that uses the log front-end.

use teensy4_bsp as bsp;
use bsp::board;

let board::Resources { usb, .. } = board::t40(board::instances());
bsp::LoggingFrontend::default_log().register_usb(usb);
log::info!("Hello world!");

Register a USB logger that uses the defmt front-end.

// Same as above...
bsp::LoggingFrontend::Defmt.register_usb(usb);
defmt::info!("Hello world!");

Variants§

§

Log(LoggingConfig)

Use the log crate to write textual log messages.

The logging configuration is optional; use default_log() to select a reasonable default.

§

Defmt

Use the defmt crate to write compressed messages.

defmt requires additional setup in order to properly build your application. Consult the defmt documentation for specifics.

Implementations§

source§

impl LoggingFrontend

source

pub const fn default_log() -> Self

Creates a log front-end with a default configuration.

source

pub fn register_usb(self, _: Instances<1>)

Register the USB logger.

This method internally defines a USB1 interrupt handler named USB_OTG1. When this call returns, the interrupt is unmasked and may periodically execute.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.