macro_rules! log {
($to_log_params: expr, $($args:tt)*) => { ... };
}
Expand description
log a message to rosout
§Examples
use rclrs::*;
use std::sync::Mutex;
use std::time::Duration;
use std::env;
let executor = rclrs::Context::default().create_basic_executor();
let node = executor.create_node("test_node").unwrap();
log!(node.debug(), "Simple debug message");
let some_variable = 43;
log!(node.debug(), "Formatted debug message: {some_variable}");
log!(node.fatal(), "Fatal message from {}", node.name());
log!(node.warn().once(), "Only log this the first time");
log!(
node
.error()
.skip_first()
.throttle(Duration::from_millis(1000)),
"Noisy error that we expect the first time"
);
let count = 0;
log!(
node
.info()
.throttle(Duration::from_millis(1000))
.only_if(count % 10 == 0),
"Manually constructed LogConditions",
);
All of the above examples will also work with the severity-specific log macros, but any severity that gets passed in will be overridden:
§Panics
It is theoretically possible for the call to panic if the Mutex used for the throttling is poisoned although this should never happen.