#defmt #log #logging #back-end #log-messages

no-std log-to-defmt

A backend for log that emits through defmt

1 unstable release

0.1.0 Jan 2, 2023

#17 in #defmt

Download history 3/week @ 2023-12-18 1/week @ 2024-01-15 16/week @ 2024-01-22 4/week @ 2024-01-29 20/week @ 2024-02-05 23/week @ 2024-02-12 25/week @ 2024-02-19 32/week @ 2024-02-26 15/week @ 2024-03-04 7/week @ 2024-03-11 12/week @ 2024-03-18 2/week @ 2024-03-25 42/week @ 2024-04-01

64 downloads per month

MIT/Apache

6KB

log-to-defmt

This is a logging adapter that acts as an implementation of the log crate and hands the rendered messages off to the defmt crate.

Using this is generally not recommended: Once the log infrastructure is pulled into a project, Rust's string formatting is brought in, avoiding which is a big part of the point of defmt.

However, this can be useful during development, when debugging a particular library (that optionally produces messages through log) on a platform for which a defmt output has already been established.

Maturity

The current implementation of this takes a huge amount of shortcuts: not only does it not convert log levels, it also hardwires some to the most verbose level, discards lots of information that would otherwise be available, and uses a fixed size buffer.

Future iterations of this crate are expected to address these on demand; for example, this could gain a build time configuration mechanism for the maximum expected length, or an alloc feature that renders the log messages to a Vec instead of a heapless::Vec before handing them off to defmt as a slice.

The crate will likely introduce such features (altering its behavior) without declaring breaking changes; users are advised to configure their error levels to match which messages they expect to see.

License: MIT OR Apache-2.0

Dependencies

~1.1–1.8MB
~37K SLoC