Struct slog_extlog::stats::StatsLoggerBuilder[][src]

pub struct StatsLoggerBuilder<T> where
    T: StatisticsLogFormatter
{ pub stats: Vec<StatDefinitions>, pub stat_formatter: PhantomData<T>, }

A builder to allow customization of stats config. This gives flexibility when the other methods are insufficient.

Create the builder using new() and chain other methods as required, ending with fuse() to return the StatsConfig.

Example

Creating a config with a custom stats interval and the default formatter.


slog_extlog::define_stats! {
    MY_STATS = {
        SomeStat(Counter, "A test counter", []),
        SomeOtherStat(Counter, "Another test counter", [])
    }
}

let full_stats = vec![MY_STATS];
let logger = slog::Logger::root(slog::Discard, slog::o!());
let stats = StatsLoggerBuilder::<DefaultStatisticsLogFormatter>::default()
    .with_stats(full_stats)
    .fuse(logger);

Fields

stats: Vec<StatDefinitions>

The list of statistics to track. This MUST be created using the define_stats macro.

stat_formatter: PhantomData<T>

An object that handles formatting the individual statistic values into a log.

Implementations

impl<T: StatisticsLogFormatter> StatsLoggerBuilder<T>[src]

pub fn with_stats(self, stats: Vec<StatDefinitions>) -> Self[src]

Set the list of statistics to track.

pub fn fuse(self, logger: Logger) -> StatisticsLogger<T>[src]

Construct the StatisticsLogger - this will start the interval logging if requested.

Trait Implementations

impl<T: Debug> Debug for StatsLoggerBuilder<T> where
    T: StatisticsLogFormatter
[src]

impl<T> Default for StatsLoggerBuilder<T> where
    T: StatisticsLogFormatter
[src]

Auto Trait Implementations

impl<T> RefUnwindSafe for StatsLoggerBuilder<T> where
    T: RefUnwindSafe

impl<T> Send for StatsLoggerBuilder<T>

impl<T> Sync for StatsLoggerBuilder<T>

impl<T> Unpin for StatsLoggerBuilder<T> where
    T: Unpin

impl<T> UnwindSafe for StatsLoggerBuilder<T> where
    T: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> SendSyncUnwindSafe for T where
    T: Send + Sync + UnwindSafe + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.