Skip to main content

Module pool

Module pool 

Source
Expand description

phase-417 W4.d — bounded storage so get_or_create_logger can hand out a logger for a name nobody registered at compile time.

§The gap this closes

crate::get_logger is a LOOKUP: it answers with crate::DEFAULT_LOGGER for any name no 'static crate::Logger was crate::register_loggered under. That is correct for the Rust call sites it was written for, which declare their logger as a static. It is the wrong answer for a wrapper: rclcpp::get_logger("x") and rcutils_get_logger("x") CREATE, so a C caller doing

rclc_logger_set_level(rclc_log_get_logger("nav"), RCLC_LOG_SEVERITY_DEBUG);

over a lookup-only implementation would silently have moved the threshold of the catch-all logger every other unregistered name also resolves to — compile, and differ. RFC-0089 forbids exactly that, so the creation has to be real, and by RFC-0019 it has to be real HERE rather than in nros-c.

§Bounded, because no_std

Two static arenas, both sized by the NROS_LOG_DYNAMIC_LOGGERS knob (phase-479 W5, RFC-0102 D5 — see build.rs for its ladder): one for the crate::Logger values, one for their names (a &'static str is what Logger holds, and a const char * from C is not one). Exhaustion is REPORTED, never silently aliased onto the default logger — see crate::get_or_create_logger.

Constants§

MAX_LOGGER_NAME_LEN
Longest logger name the arena will accept, in bytes.

Functions§

dynamic_logger_capacity
How many loggers crate::get_or_create_logger may create.
dynamic_logger_name_arena
Bytes of the name arena spent, and its total size.
dynamic_loggers_in_use
How many of the dynamic_logger_capacity slots are spent.