Skip to main content

get_or_create_logger

Function get_or_create_logger 

Source
pub fn get_or_create_logger(name: &str) -> Option<&'static Logger>
Expand description

Look up a logger by name, CREATING one if the name is new.

phase-417 W4.d. This is the shape rclcpp::get_logger / rcutils’ logger lookup have, and the one a wrapper needs: get_logger answers DEFAULT_LOGGER for an unregistered name, so a C or C++ caller doing set_level(get_logger("nav"), Debug) over the lookup-only form would have moved the threshold of the catch-all logger that EVERY other unregistered name also resolves to. Same call, same types, different effect — precisely the compile-and-differ RFC-0089 forbids.

Storage is the bounded static arena in pool, sized by the NROS_LOG_DYNAMIC_LOGGERS knob (RFC-0102 D5: env > board > 16). Returns None — never a logger under the wrong name — when:

Callers decide what an exhausted arena means for them; nros-c reports it and falls back to DEFAULT_LOGGER loudly rather than silently.

Loggers created this way are never destroyed — the arena has no free list, which is what makes the returned &'static Logger honest on no_std.