timely::logging_core

Struct Registry

Source
pub struct Registry { /* private fields */ }
Expand description

A registry binding names to typed loggers.

Implementations§

Source§

impl Registry

Source

pub fn insert<CB, F>(&mut self, name: &str, action: F) -> Option<Box<dyn Any>>
where CB: ContainerBuilder, F: FnMut(&Duration, &mut Option<<CB as ContainerBuilder>::Container>) + 'static,

Binds a log name to an action on log event batches.

This method also returns any pre-installed action, rather than overwriting it and pivoting the logging destination mid-stream. New loggers with this name will use the new destination, and existing loggers will use the old destination.

The action should respond to a sequence of events with non-decreasing timestamps (Durations) and well as a timestamp that lower bounds the next event that could be seen (likely greater or equal to the timestamp of the last event). The end of a logging stream is indicated only by dropping the associated action, which can be accomplished with remove (or a call to insert, though this is not recommended).

The action needs to follow the requirements of container builder CB regarding what they need to do with containers they receive and what properties to uphold.

Passing a &mut None container to an action indicates a flush.

Source

pub fn insert_logger<CB>( &mut self, name: &str, logger: Logger<CB>, ) -> Option<Box<dyn Any>>
where CB: ContainerBuilder,

Binds a log name to a logger.

Source

pub fn remove(&mut self, name: &str) -> Option<Box<dyn Any>>

Removes a bound logger.

This is intended primarily to close a logging stream and let the associated writer communicate that the stream is closed to any consumers. If a binding is not removed, then the stream cannot be complete as in principle anyone could acquire a handle to the logger and start further logging.

Source

pub fn get<CB>(&self, name: &str) -> Option<Logger<CB>>
where CB: ContainerBuilder,

Retrieves a shared logger, if one has been inserted.

Source

pub fn new(time: Instant) -> Registry

Creates a new logger registry.

Source

pub fn flush(&mut self)

Flushes all registered logs.

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CopyAs<T> for T

Source§

fn copy_as(self) -> T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

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

Source§

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.