pub struct StatisticsLogger { /* private fields */ }
Expand description

A logger with statistics tracking.

This should only be created through the new method.

Implementations§

source§

impl StatisticsLogger

source

pub fn with_params<P>(&self, params: OwnedKV<P>) -> Selfwhere P: SendSyncRefUnwindSafeKV + 'static,

Build a child logger with new parameters.

This is essentially a wrapper around slog::Logger::new().

source

pub fn update_stats(&self, log: &dyn StatTrigger)

Update the statistics for the current log.

source

pub fn set_slog_logger(&mut self, logger: Logger)

Modify the logger field without changing the stats tracker

source

pub fn get_stats(&self) -> Vec<StatSnapshot>

Retrieve the current values of all stats tracked by this logger.

Methods from Deref<Target = Logger>§

source

pub fn new<T>(&self, values: OwnedKV<T>) -> Logger<D>where T: SendSyncRefUnwindSafeKV + 'static, D: Clone,

Build a child logger

Child logger inherits all existing key-value pairs from its parent and supplements them with additional ones.

Use o! macro to build OwnedKV object.

Drain cloning (D : Clone requirement)

All children, their children and so on, form one tree sharing a common drain. This drain, will be Cloned when this method is called. That is why Clone must be implemented for D in Logger<D>::new.

For some Drain types Clone is cheap or even free (a no-op). This is the case for any Logger returned by Logger::root and its children.

When using Logger::root_typed, it’s possible that cloning might be expensive, or even impossible.

The reason why wrapping in an Arc is not done internally, and exposed to the user is performance. Calling Drain::log through an Arc is tiny bit slower than doing it directly.

#[macro_use]
extern crate slog;

fn main() {
    let root = slog::Logger::root(slog::Discard,
        o!("key1" => "value1", "key2" => "value2"));
    let _log = root.new(o!("key" => "value"));
}
source

pub fn log(&self, record: &Record<'_>)

Log one logging Record

Use specific logging functions instead. See log! macro documentation.

source

pub fn list(&self) -> &OwnedKVList

Get list of key-value pairs assigned to this Logger

source

pub fn to_erased(&self) -> Loggerwhere D: SendRefUnwindSafeDrain + 'static + Clone,

Create a copy with “erased” type

See into_erased

Trait Implementations§

source§

impl Clone for StatisticsLogger

source§

fn clone(&self) -> StatisticsLogger

Returns a copy 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 Debug for StatisticsLogger

source§

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

Formats the value using the given formatter. Read more
source§

impl Deref for StatisticsLogger

§

type Target = Logger

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. 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 Twhere 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 Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.
source§

impl<T> SendSyncUnwindSafe for Twhere T: Send + Sync + UnwindSafe + ?Sized,