Skip to main content

Module macros

Module macros 

Source
Expand description

Phase 88.2 — the emission macros.

Each macro formats its arguments into a stack-resident crate::FormatBuffer (capacity picked at compile time by the buffer-size-<N> feature), wraps the result in a crate::Record, and hands it to the crate::Logger’s dispatcher.

Compile-time ceiling: macros below crate::compile_time_ceiling expand to () — the format call is dead-code-eliminated.

§Naming (RFC-0089, settled 2026-09-04)

The three ROS 2 client libraries disagree with each other about how to spell a log line:

rclrs    log_info!(logger, "…")        <- Rust follows THIS
rclcpp   RCLCPP_INFO(logger, "…")
rcutils  RCUTILS_LOG_INFO_NAMED(…)

There is no single “ROS 2 spelling”, so each of our languages follows ITS OWN upstream. For Rust that is rclrs, and rclrs’s five severity macros are log_debug!, log_info!, log_warn!, log_error! and log_fatal! — which is what this module now exports. (They carry an explicit target because #[macro_export] puts a macro at the CRATE ROOT, not in the module whose file declares it.) The pre-rename nros_debug! .. nros_fatal! forwarders, and the deprecate-legacy-names feature that armed their #[deprecated], were removed in phase-417 W-B5 once every in-tree call site had moved. There is no log_trace!: see below.

A name takes rclrs’s spelling exactly when rclrs HAS that name. Two families deliberately keep the nros_ prefix, because inventing a name inside rclrs’s namespace-alike would claim an upstream twin that does not exist:

  • nros_trace! — rclrs stops at debug. TRACE is ours (ledger rust:nros_trace, verdict extension), so it keeps a name that says so.
  • the nros_*_throttle! / nros_*_throttle_at! family — rclrs expresses throttling as a modifier on ONE macro (log_info!(logger.throttle(Duration::from_millis(500)), "…") via LogParams / ToLogParams), not as a macro per severity. Ours is a different DECOMPOSITION of the same capability, already ledgered as divergence; see that family’s own note for what adopting rclrs’s shape would cost.