[][src]Struct log_reroute::Reroute

pub struct Reroute { /* fields omitted */ }

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 (unless there's a lot of contention and the slave logger also doesn't lock), it makes it usable in some weird places (like a signal handler).

The rerouting (eg. changing the slave) is lock-less, but may have to wait for current logging calls to end and concurrent reroutes will block each other.

Note

When switching a logger, no care is taken to pair logging calls. In other words, it is possible a message is written to the old logger and the new logger is flushed. This shouldn't matter in practice, since a logger should flush itself once it is dropped.

Methods

impl Reroute[src]

pub fn reroute_boxed(&self, log: Box<dyn Log>)[src]

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 payed here.

pub fn reroute<L: Log + 'static>(&self, log: L)[src]

Sets a new slave logger.

pub fn clear(&self)[src]

Stubs out the logger.

Sets the slave logger to one that does nothing (eg. Dummy).

Trait Implementations

impl Default for Reroute[src]

fn default() -> Self[src]

Creates a reroute with a Dummy slave logger.

impl Log for Reroute[src]

Auto Trait Implementations

impl Send for Reroute

impl Sync for Reroute

Blanket Implementations

impl<T> From for T[src]

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.