Skip to content

refactor: drop the defmt mirrors the log macros now cover (#352, 3/3) - #360

Merged
lxsaah merged 1 commit into
feat/352-log-defmtfrom
fix/352-drop-mirrors
Oct 24, 2026
Merged

lxsaah merged 1 commit into
feat/352-log-defmtfrom
fix/352-drop-mirrors

Conversation

@lxsaah

@lxsaah lxsaah commented Oct 24, 2026

Copy link
Copy Markdown
Member

Description

PR 3 of 3 into feat/352-log-defmt for #352. Since PR 2 (#359), the log_*! macros forward to defmt. A hand-written #[cfg(feature = "defmt")] defmt::…! next to a log_*! line therefore logs the same event twice on the device.

Removed: the 7 real pairs (defmt mirror right after a log_*! call, same event and arguments):

File Event
aimdb-core/src/router.rs (3) ingest failed; route matched but not produced; no route
aimdb-core/src/session/client.rs (1) mirror gap (updates lost)
aimdb-mqtt-connector/src/embedded/mod.rs (2) inbound/outbound route asks for qos=2, capped at 1
aimdb-mqtt-connector/src/embedded/session_loop.rs (1) oversized publish skipped

Some of the mirrors had shortened the text. The device now shows the full log_*! text, which costs no flash at runtime because defmt interns its strings.

Kept on purpose: the standalone defmt calls with no log_*! counterpart, which are the only output for their events: the MQTT connector's embedded backend (connect, TLS, SNTP, session errors, …) and the Embassy adapter (runtime logger, slot error). #352 estimated "30 mirrors", but that counted every direct defmt call; only these 7 are duplicates. Turning the standalone calls into log_*! (so they'd also show up in host builds of the embedded backend) would be a separate change.

Live on the NUCLEO-H563ZI (feature branch with PR 1–3; temporarily with a TCP server on port 0 and a record without a free slot). Everything that used to be invisible shows up in the device's defmt log:

ERROR accept failed: Io; retrying, further failures are summarized
WARN  accept still failing: 10 attempts in a row, last: Io
WARN  accept still failing: 100 attempts in a row, last: Io
WARN  accept still failing: 10000 attempts in a row, last: Io
WARN  accept still failing: 100000 attempts in a row, last: Io
INFO  new handshake on a live connection: ending 1 subscription(s) of the previous client
ERROR AimDB: SpmcRing subscriber slot exhausted (max SUBS=2) …
WARN  subscription 2 ended: its source closed

The summary for 1,000 attempts doesn't appear. The unit test from #351 covers that logic; the likely cause is defmt-rtt dropping lines when its buffer fills during the startup burst. Afterwards the board was flashed back to the clean demo.

Verified locally: all 58 Makefile commands for aimdb-core and aimdb-mqtt-connector (tests, clippy, every thumbv7em check/clippy, including defmt and TLS).

Afterwards: changelogs on the feature branch, then the PR to main, the first full CI run over #352.

Related Issue

🤖 Generated with Claude Code

https://claude.ai/code/session_01YPDjQ947yKjLLAq3Xzgu3e

Since the `log_*!` macros forward to defmt (#359), a hand-written
`#[cfg(feature = "defmt")] defmt::…!` next to a `log_*!` line logs the same
event twice on the device. Removes the seven such pairs: three in
`aimdb-core`'s router, one in its session client (mirror gap), three in the
MQTT connector's embedded backend (qos=2 caps, oversized publish). The device
now shows the `log_*!` text, which some of the mirrors had shortened.

The defmt-only calls stay: they have no `log_*!` counterpart (the MQTT
embedded backend's connect/TLS/SNTP lines, the Embassy adapter's runtime
logger and slot error).

Part of #352.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YPDjQ947yKjLLAq3Xzgu3e
@lxsaah
lxsaah merged commit fd5b1da into feat/352-log-defmt Oct 24, 2026
@lxsaah lxsaah mentioned this pull request Oct 24, 2026
3 of 5 tasks
@lxsaah
lxsaah deleted the fix/352-drop-mirrors branch October 24, 2026 20:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant