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
impl StatisticsLogger
Sourcepub fn with_params<P>(&self, params: OwnedKV<P>) -> Selfwhere
P: SendSyncRefUnwindSafeKV + 'static,
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().
Sourcepub fn update_stats(&self, log: &dyn StatTrigger)
pub fn update_stats(&self, log: &dyn StatTrigger)
Update the statistics for the current log.
Sourcepub fn set_slog_logger(&mut self, logger: Logger)
pub fn set_slog_logger(&mut self, logger: Logger)
Modify the logger field without changing the stats tracker
Sourcepub fn get_stats(&self) -> Vec<StatSnapshot>
pub fn get_stats(&self) -> Vec<StatSnapshot>
Retrieve the current values of all stats tracked by this logger.
Methods from Deref<Target = Logger>§
Sourcepub fn new<T>(&self, values: OwnedKV<T>) -> Logger<D>where
T: SendSyncRefUnwindSafeKV + 'static,
D: Clone,
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.
use slog::o;
let root = slog::Logger::root(
slog::Discard,
o!("key1" => "value1", "key2" => "value2"),
);
let _log = root.new(slog::o!("key" => "value"));Sourcepub fn log(&self, record: &Record<'_>)
pub fn log(&self, record: &Record<'_>)
Log one logging Record
Use specific logging functions instead. See log! macro
documentation.
Sourcepub fn flush(&self) -> Result<(), FlushError>
pub fn flush(&self) -> Result<(), FlushError>
Flush all pending log records, blocking until completion.
In many cases this is equivalent to calling std::io::Write::flush on the underlying stream.
See docs on Drain::flush for more details.
Returns FlushError::NotSupported if the underlying drain does not support Drain::flush.
Sourcepub fn list(&self) -> &OwnedKVList
pub fn list(&self) -> &OwnedKVList
Get list of key-value pairs assigned to this Logger
Sourcepub fn to_erased(&self) -> Loggerwhere
D: SendRefUnwindSafeDrain + 'static + Clone,
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
impl Clone for StatisticsLogger
Source§fn clone(&self) -> StatisticsLogger
fn clone(&self) -> StatisticsLogger
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more