pub struct Registry { /* private fields */ }
Expand description
A registry binding names to typed loggers.
Implementations§
Source§impl Registry
impl Registry
Sourcepub 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,
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.
Sourcepub fn insert_logger<CB>(
&mut self,
name: &str,
logger: Logger<CB>,
) -> Option<Box<dyn Any>>where
CB: ContainerBuilder,
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.
Sourcepub fn remove(&mut self, name: &str) -> Option<Box<dyn Any>>
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.