pub trait StatsLogger: Send {
    fn group_start(&mut self);
    fn group_log(&mut self, id: Id, value: LogValue) -> Result<(), LogError>;
    fn group_end(&mut self);
    fn flush(&mut self);

    fn log(&mut self, id: Id, value: LogValue) -> Result<(), LogError> { ... }
    fn group(self) -> LogGroup<Self>
    where
        Self: Sized
, { ... } fn with_scope(self, scope: &'static str) -> ScopedLogger<Self>
    where
        Self: Sized
, { ... } fn log_counter_increment(&mut self, name: &'static str, increment: u64) { ... } fn log_duration(&mut self, name: &'static str, duration: Duration) { ... } fn log_elapsed<F, T>(&mut self, name: &'static str, f: F) -> T
    where
        F: FnOnce(&mut Self) -> T,
        Self: Sized
, { ... } fn log_scalar(&mut self, name: &'static str, value: f64) { ... } fn log_index(&mut self, name: &'static str, value: usize, size: usize) { ... } }
Expand description

Log a time series of statistics.

Statistics with the same name may be aggregated or summarized over some time period.

Required Methods

Internal helper. Do not call directly. Handle the creation of a LogGroup. May flush.

Internal helper. Do not call directly. Log a value within a LogGroup. May not flush.

Internal helper. Do not call directly. Handle the drop of a LogGroup. May flush.

Record any remaining data in the logger that has not yet been recorded.

Provided Methods

Log a value associated with an ID.

Args
  • id - Unique identifier of the statistic to log. Used to track the value over time. It is an error to use the same identifier with values that have different LogValue variants or are otherwise structurally incompatible.

    The ID can be created from a string with into(). It is a hierarchical name, similar to a file system path. Logger scope names (created with StatsLogger::with_scope) will be prepended to the given ID.

  • value - The value to log.

Create a logger for a group of related values.

Once the group has been created, no flushing will occur until the group is dropped.

This can be called on a reference for a temporary group: (&mut logger).group()

Wrap this logger such that an inner scope is added to all logged ids.

This can be called on a reference for a temporary scope: (&mut logger).with_scope(...)

Log an increment to a named counter (convenience function).

Panics if this name was previously used to log a value of a different type.

Log a named duration (convenience function).

Panics if this name was previously used to log a value of a different type.

Log a named duration as the elapsed time in evaluating a closure.

The closure is passed a mutable reference to this logger so that it has the opportunity to make its own logging calls.

Log a named scalar value (convenience function).

Panics if this name was previously used to log a value of a different type.

Log a named index in 0 to size - 1 (convenience function).

Panics if this name was previously used to log a value of a different type or an index value with a different size.

Implementations on Foreign Types

No-op logger

Pair of loggers; logs to both.

Implementors