Expand description
Logging backend: routes the log-04 facade into a static ring buffer
which is drained over the USB-CDC connection.
Architecture:
log::info!(...) ─► Logger ─► push_line() ─► CDC ring (4 KiB, drop-oldest)
▲
panic_report (raw, bypasses level filter)
usb.rs class_task: cdc_peek ─► write_packet ─► cdc_commit ─► inv monitorThe ring is a static, allocation-free byte buffer. Producers append formatted lines (oldest bytes are overwritten when full), the single consumer in the USB class task copies chunks out with peek/commit so a cancelled write never loses data.
Structs§
- LogRing 🔒
- Single-producer/single-consumer byte ring with overwrite-oldest policy.
- Logger 🔒
log::Logimplementation that formats records intoCDC_RING.- State 🔒
- Raw ring contents guarded by
LogRing’s critical sections.
Constants§
- LINE_
MAX 🔒 - Maximum formatted length of one log line, prefix and newline included.
- RING_
SIZE 🔒 - Total CDC ring capacity in bytes (power of two).
Statics§
- CDC_
RING 🔒 - Global CDC ring: shared by every producer and the USB drain task.
- LOGGER 🔒
- Static logger instance registered by
init. - READY 🔒
- Set once
initran; gates embassy-time access (the time driver only starts withesp_rtos::start(), before thatInstant::now()would panic).
Functions§
- cdc_
commit 🔒 - Mark the
nbytes previously returned bycdc_peekas consumed. - cdc_
peek 🔒 - Copy as much pending data as fits into
outwithout consuming it. - configured_
level 🔒 - Map the
LOG_LEVELbuild env to a max level; unknown values fall back to Info. - drain_
snapshot 🔒 - Move the ring contents since
mark_snapshot_floorintoout, dropping the oldest bytes if needed so the newest data always fits. Consumes everything. - init
- Initialize the global logger.
- level_
marker 🔒 - One-character level marker used in the line prefix.
- mark_
snapshot_ 🔒floor - Mark the current write position as the earliest byte a panic snapshot may contain, called after the boot-time replay.
- push_
line 🔒 - Format one prefixed line (
[<uptime>ms][<marker>] <args>\n) into the CDC ring. Used by thelog::Logimplementation and bypanic_report(which bypasses the log level filter). - push_
raw 🔒 - Append bytes verbatim to the CDC ring (no prefix, no newline handling).
- uptime_
ms 🔒 - Milliseconds since boot;
0before the embassy time driver runs.