Expand description
A highly efficient logging framework that targets resource-constrained devices, like microcontrollers.
Check out the defmt book at https://defmt.ferrous-systems.com for more information about how to use it.
§Compatibility
The defmt
wire format might change between minor versions. Attempting to
read a defmt stream with an incompatible version will result in an error,
and any tool used to process that stream should first check for a symbol
named like _defmt_version_ = X
, where X indicates the wire format version
in use.
Updating your version of defmt might mean you also have to update your
version of defmt-print
or defmt-decoder
.
Macros§
- assert
- Just like the
core::assert!
macro butdefmt
is used to log the panic message - assert_
eq - Just like the
core::assert_eq!
macro butdefmt
is used to log the panic message - assert_
ne - Just like the
core::assert_ne!
macro butdefmt
is used to log the panic message - bitflags
- Generates a bitflags structure that can be formatted with defmt.
- dbg
- Just like the
std::dbg!
macro butdefmt
is used to log the message atTRACE
level. - debug
- Logs data at debug level.
- debug_
assert - Just like the
core::debug_assert!
macro butdefmt
is used to log the panic message - debug_
assert_ eq - Just like the
core::debug_assert_eq!
macro butdefmt
is used to log the panic message - debug_
assert_ ne - Just like the
core::debug_assert_ne!
macro butdefmt
is used to log the panic message - error
- Logs data at error level.
- expect
- This is an alias for defmt’s
unwrap
macro which supports messages like std’s except. - info
- Logs data at info level.
- intern
- Creates an interned string (
Str
) from a string literal. - panic
- Just like the
core::panic!
macro butdefmt
is used to log the panic message - println
- Always logs data irrespective of log level.
- timestamp
- Defines the global timestamp provider for defmt.
- todo
- Just like the
core::todo!
macro butdefmt
is used to log the panic message - trace
- Logs data at trace level.
- unimplemented
- Just like the
core::unimplemented!
macro butdefmt
is used to log the panic message - unreachable
- Just like the
core::unreachable!
macro butdefmt
is used to log the panic message - unwrap
- Unwraps an
Option
orResult
, panicking if it isNone
orErr
. - warn
- Logs data at warn level.
- write
- Writes formatted data to a
Formatter
.
Structs§
- Debug2
Format - An “adapter” type to feed
Debug
values into defmt macros, which expectdefmt::Format
values. - Display2
Format - An “adapter” type to feed
Display
values into defmt macros, which expectdefmt::Format
values. - Encoder
- Encode raw defmt frames for sending over the wire.
- Formatter
- Handle to a defmt logger.
- Str
- An interned string created via
intern!
.
Traits§
Functions§
- flush
- Block until host has read all pending data.
Attribute Macros§
- global_
logger - Defines the global defmt logger.
- panic_
handler - Overrides the panicking behavior of
defmt::panic!