Trait relearn::logging::StatsLogger
source · [−]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
fn group_start(&mut self)
fn group_start(&mut self)
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.
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 differentLogValue
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 withStatsLogger::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()
fn with_scope(self, scope: &'static str) -> ScopedLogger<Self> where
Self: Sized,
fn with_scope(self, scope: &'static str) -> ScopedLogger<Self> where
Self: Sized,
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(...)
fn log_counter_increment(&mut self, name: &'static str, increment: u64)
fn log_counter_increment(&mut self, name: &'static str, increment: u64)
Log an increment to a named counter (convenience function).
Panics if this name was previously used to log a value of a different type.
fn log_duration(&mut self, name: &'static str, duration: Duration)
fn log_duration(&mut self, name: &'static str, duration: Duration)
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.
fn log_scalar(&mut self, name: &'static str, value: f64)
fn log_scalar(&mut self, name: &'static str, value: f64)
Log a named scalar value (convenience function).
Panics if this name was previously used to log a value of a different type.
Implementations on Foreign Types
sourceimpl<T> StatsLogger for &mut T where
T: StatsLogger + ?Sized,
impl<T> StatsLogger for &mut T where
T: StatsLogger + ?Sized,
sourceimpl<T> StatsLogger for Box<T> where
T: StatsLogger + ?Sized,
impl<T> StatsLogger for Box<T> where
T: StatsLogger + ?Sized,
sourceimpl StatsLogger for ()
impl StatsLogger for ()
No-op logger
sourceimpl<A, B> StatsLogger for (A, B) where
A: StatsLogger,
B: StatsLogger,
impl<A, B> StatsLogger for (A, B) where
A: StatsLogger,
B: StatsLogger,
Pair of loggers; logs to both.