Expand description
A tiny logging facade that forwards to [defmt], [tracing], both, or
neither, chosen by Cargo features.
Consortium spans no_std firmware (which logs with defmt) and std
host-side tooling such as the config codegen (which logs with tracing).
This crate lets a single call site — consortium_log::trace!(...) — compile
against whichever backend the consuming crate turns on:
defmtroutes each macro to the matchingdefmtmacro.tracingroutes each macro to the matchingtracingmacro.tracingalso enablesallocbecause thetracingdependency needs it.- With both enabled, every event is emitted to both backends.
- With neither enabled, the macros expand to nothing.
§Format syntax
The portable subset is a format string plus positional arguments —
trace!("channel {} lowered", name) — or Rust-style implicit captures —
trace!("channel {name} lowered"). Implicit captures are normalized to
indexed arguments before being forwarded, because defmt does not parse
them itself. Each argument must implement the traits both backends require
(defmt::Format for defmt, core::fmt::Display/Debug for tracing).
Backend-specific extensions (defmt’s {=u8} type hints, tracing’s
structured fields) are only valid when that backend is the sole one enabled.
Log arguments must be side-effect free: when no backend is enabled the macros expand to nothing and the arguments are never evaluated.
§Features
defmt— forward to thedefmtlogging macros.defmt’s proc-macros expand to literaldefmt::…paths resolved at the call site, so a crate that enables this backend must also depend ondefmtdirectly (the facade cannot supply the name). The workspace’s firmware crates already do.tracing— forward to thetracinglogging macros (impliesalloc).tracing’s macros are$crate-hygienic, so no direct dependency is needed beyond this crate.alloc— marker capability required bytracing; enabling it alone pulls no backend.
Macros§
- debug
- Logs at the
debuglevel to every enabled backend. - error
- Logs at the
errorlevel to every enabled backend. - info
- Logs at the
infolevel to every enabled backend. - trace
- Logs at the
tracelevel to every enabled backend. See the crate docs for the portable format syntax. - warn
- Logs at the
warnlevel to every enabled backend.