Skip to main content

Module early

Module early 

Source
Expand description

Records raised before any sink was installed.

§The problem this exists for

crate::init publishes the sink list. A record raised before that call has nowhere to go, and for most of this crate’s life it was constructed, dispatched and DROPPED — silently, and invisibly to its author, who cannot know what the board did before reaching their code.

Issue 0708 answered by requiring every board boot funnel to call init_default(), gated on funnels spelled pub fn run*. That is a SEARCH for boot paths and it kept losing: NuttX’s funnel is pub extern "C" fn nsh_main, and three board crates did not link nros-log in the configuration holding the funnel at all.

Issue 0710 answered by having dispatch install the platform sink itself. That removed the search — but it put nros_platform_log_write on a path EVERY binary executes, which turned a pluggable delivery into a LINK-TIME requirement. Seven test targets in nros-rmw-cffi and most of nros-tests stopped linking under check-workspace-features, and no Cargo feature can fix that: nros-platform-cffi and nros-rmw-bridge enable nros-node/rmw-cffi unconditionally, so feature unification turns any forwarded gate back ON for every member of a workspace build. A feature is a property of the BUILD; what the question needs is a property of the BINARY.

§What this does instead

Hold the records. A record raised with no sinks installed is copied into a bounded static ring here; crate::init drains it into whatever sinks the board actually chose. Nothing is dropped, no board can forget, and this crate touches no platform symbol to do it — the facade stays a facade.

It is also STRICTLY better than installing a default sink was: the early records land in the sink the board picked, rather than in whichever one dispatch guessed before the board had spoken.

§Cost, and how to decline it

EARLY_DEPTH * (format buffer + name + header) of static RAM, all of it in .bss. The depth is chosen by the early-records-<N> feature family the same way buffer-size-<N> picks the format buffer, and for the same reason — a 64 KB MCU and a Linux host do not want the same number. 0 declines the buffer entirely and restores the pre-0708 behaviour of dropping, with the count below still kept so the loss is at least reportable.

Overflow is counted, never silently absorbed: overflowed returns how many records did not fit, and init reports it through the freshly installed sinks.

Functions§

early_depth
Records held before init. See the module docs for the trade.
overflowed
How many early records did not fit and were lost.