Skip to main content

Logger

Struct Logger 

Source
pub struct Logger<'a> { /* private fields */ }
Expand description

A logger associated with a ROS node

Provides methods for logging at different severity levels. The logger includes the node name in log output for context.

Implementations§

Source§

impl<'a> Logger<'a>

Source

pub const fn new(node_name: &'a str) -> Logger<'a>

Create a new logger for the given node name

Source

pub const fn node_name(&self) -> &str

Get the node name associated with this logger

Source

pub fn debug(&self, message: &str)

Log a message at the DEBUG level

Source

pub fn info(&self, message: &str)

Log a message at the INFO level

Source

pub fn warn(&self, message: &str)

Log a message at the WARN level

Source

pub fn error(&self, message: &str)

Log a message at the ERROR level

Source

pub fn trace(&self, message: &str)

Log a message at the TRACE level

Source

pub fn debug_once(&self, flag: &OnceFlag, message: &str)

Log a DEBUG message only once (first call only)

The flag should be a static OnceFlag to track whether the message has already been logged.

Source

pub fn info_once(&self, flag: &OnceFlag, message: &str)

Log an INFO message only once (first call only)

Source

pub fn warn_once(&self, flag: &OnceFlag, message: &str)

Log a WARN message only once (first call only)

Source

pub fn error_once(&self, flag: &OnceFlag, message: &str)

Log an ERROR message only once (first call only)

Source

pub fn trace_once(&self, flag: &OnceFlag, message: &str)

Log a TRACE message only once (first call only)

Source

pub fn debug_skip_first(&self, flag: &OnceFlag, message: &str)

Log a DEBUG message, skipping the first occurrence

The flag should be a static OnceFlag to track whether the first call has been skipped.

Source

pub fn info_skip_first(&self, flag: &OnceFlag, message: &str)

Log an INFO message, skipping the first occurrence

Source

pub fn warn_skip_first(&self, flag: &OnceFlag, message: &str)

Log a WARN message, skipping the first occurrence

Source

pub fn error_skip_first(&self, flag: &OnceFlag, message: &str)

Log an ERROR message, skipping the first occurrence

Source

pub fn trace_skip_first(&self, flag: &OnceFlag, message: &str)

Log a TRACE message, skipping the first occurrence

Source

pub fn debug_throttle( &self, last_log_time: &mut u64, current_time_ms: u64, interval_ms: u64, message: &str, )

Log a DEBUG message with rate limiting

§Arguments
  • last_log_time - Mutable reference to track last log time (in milliseconds)
  • current_time_ms - Current time in milliseconds (from your clock)
  • interval_ms - Minimum interval between logs in milliseconds
  • message - The message to log
§Example
static mut LAST_LOG: u64 = 0;
let now_ms = clock.now_ms();
// Safety: only accessed from single thread
unsafe { logger.debug_throttle(&mut LAST_LOG, now_ms, 1000, "Rate limited"); }
Source

pub fn info_throttle( &self, last_log_time: &mut u64, current_time_ms: u64, interval_ms: u64, message: &str, )

Log an INFO message with rate limiting

Source

pub fn warn_throttle( &self, last_log_time: &mut u64, current_time_ms: u64, interval_ms: u64, message: &str, )

Log a WARN message with rate limiting

Source

pub fn error_throttle( &self, last_log_time: &mut u64, current_time_ms: u64, interval_ms: u64, message: &str, )

Log an ERROR message with rate limiting

Source

pub fn trace_throttle( &self, last_log_time: &mut u64, current_time_ms: u64, interval_ms: u64, message: &str, )

Log a TRACE message with rate limiting

Trait Implementations§

Source§

impl<'a> Clone for Logger<'a>

Source§

fn clone(&self) -> Logger<'a>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Debug for Logger<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for Logger<'a>

§

impl<'a> RefUnwindSafe for Logger<'a>

§

impl<'a> Send for Logger<'a>

§

impl<'a> Sync for Logger<'a>

§

impl<'a> Unpin for Logger<'a>

§

impl<'a> UnsafeUnpin for Logger<'a>

§

impl<'a> UnwindSafe for Logger<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.