[][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, 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

impl Reroute[src]

pub fn new() -> Self[src]

Creates a new Reroute logger.

No destination is set yet (it's sent to the Dummy instance), therefore all log messages are thrown away.

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

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

Sets a slave logger.

Another variant of reroute_boxed, accepting the inner representation. This can be combined with a previous get.

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

Sets a new slave logger.

See reroute_boxed for more details.

pub fn clear(&self)[src]

Stubs out the logger.

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

pub fn get(&self) -> Arc<Box<dyn Log>>[src]

Gives access to the inner logger.

Notes

The logger may be still in use by other threads, etc. It may be in use even after the current thread called clear or reroute, at least for a while.

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 !RefUnwindSafe for Reroute

impl Send for Reroute

impl Sync for Reroute

impl Unpin for Reroute

impl !UnwindSafe for Reroute

Blanket Implementations

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

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

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

impl<T> From<T> for T[src]

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

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

type Error = Infallible

The type returned in the event of a conversion error.

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

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

The type returned in the event of a conversion error.