pub struct Reroute { /* private fields */ }
Expand description
A logging proxy.
This logger forwards all calls to currently configured slave logger.
The log routing is implemented in a lock-less and wait-less manner. While not necessarily faster than using a mutex, the performance should be more predictable and stable in face of contention from multiple threads. This assumes the slave logger also doesn’t lock.
Implementations§
Source§impl Reroute
impl Reroute
Sourcepub fn reroute_boxed(&self, log: Box<dyn Log>)
pub fn reroute_boxed(&self, log: Box<dyn Log>)
Sets a new slave logger.
In case it is already in a box, you should prefer this method over
reroute
, since there’ll be less indirection.
The old logger (if any) is flushed before dropping. In general, loggers should flush themselves on drop, but that may take time. This way we (mostly) ensure the cost of flushing is paid here.
Sourcepub fn reroute_arc(&self, log: Arc<Box<dyn Log>>)
pub fn reroute_arc(&self, log: Arc<Box<dyn Log>>)
Sets a slave logger.
Another variant of reroute_boxed
, accepting the inner
representation. This can be combined with a previous get
.
Note that the Arc<Box<dyn Log>>
(double indirection) is necessary evil, since arc-swap
can’t accept !Sized
types.
Sourcepub fn reroute<L: Log + 'static>(&self, log: L)
pub fn reroute<L: Log + 'static>(&self, log: L)
Sets a new slave logger.
See reroute_boxed
for more details.