Skip to main content

Module log_params

Module log_params 

Source
Expand description

rclrs’s log modifiers — log_info!(logger.once(), …), .skip_first(), .throttle(d), .only_if(b) (phase-515 R3).

rclrs’s five level macros take anything implementing ToLogParams as their first argument, so a modifier chains off the logger:

ⓘ
log_info!(logger.once(), "link up");
log_warn!(logger.skip_first().throttle(Duration::from_millis(500)), "lag {}", ms);
log_debug!(logger.only_if(verbose), "state {:?}", s);

ADOPT-BOUNDED. rclrs’s names, with three stated differences:

  • ToLogParams is implemented for &Logger and LogParams only. rclrs also takes a node or a logger NAME; here a node’s logger is node.logger(), and a name is crate::get_logger.
  • ThrottleClock has one variant, SteadyTime: the platform’s monotonic clock is the only clock the logging path can read. rclrs’s SystemTime and Clock(…) have nothing to name here.
  • [ToLogParams::throttle] and [ToLogParams::throttle_clock] exist only when the image has that clock (cfg(nros_log_clock), issue 1037). Without one the window would be measured against a constant and the call site would read like a working throttle while emitting once and then never (issue 1152), so a clockless build refuses .throttle(d) at compile time — the same refusal the nros_*_throttle! family makes, and the nros_*_throttle_at! family stays the clockless form.

The state once, skip_first and throttle need is NOT in the params value. As in rclrs, the level macro declares it as statics at the call site ([crate::__nros_log_params_emit!]), which is what makes it per site. A call site whose params are known at compile time to need neither — every plain log_info!(logger, …) — references neither static once optimised, and they are dropped with the dead branch.

Structs§

LogParams
rclrs’s LogParams: the logger plus the modifiers one record carries.

Enums§

LogOccurrence
rclrs’s LogOccurrence: which records of a call site emit.
ThrottleClock
rclrs’s ThrottleClock: the clock a throttle window is measured on.

Traits§

ToLogParams
rclrs’s ToLogParams: anything a level macro takes as its first argument, and the modifiers that chain off it.