[][src]Struct spirit_log::background::AsyncLogger

pub struct AsyncLogger { /* fields omitted */ }

A logger that postpones the logging into a background thread.

Note that to not lose messages, the logger need to be flushed.

Either manually:

log::logger().flush();

Or by dropping the FlushGuard (this is useful to flush even in non-success cases or as integrations with other utilities).

fn main() {
    let _guard = FlushGuard;
    // The rest of the application code.
}

Note that even with this, things like std::process::exit will allow messages to be lost.

Implementations

impl AsyncLogger[src]

pub fn new(logger: Box<dyn Log>, buffer: usize, mode: OverflowMode) -> Self[src]

Sends the given logger to a background thread.

Params

  • logger: The logger to use in the background thread.
  • buffer: How many messages there can be waiting in the channel to the background thread.
  • mode: What to do if a message doesn't fit into the channel.

Panics

  • If the buffer size is 0.
  • If the AdaptiveDrop fill_limit is zero or larger or equal to buffer.

Trait Implementations

impl Drop for AsyncLogger[src]

fn drop(&mut self)[src]

Flushes the logger before going away, to make sure log messages are not lost.

As much as it's possible to ensure.

impl Log for AsyncLogger[src]

Auto Trait Implementations

impl !RefUnwindSafe for AsyncLogger

impl Send for AsyncLogger

impl Sync for AsyncLogger

impl Unpin for AsyncLogger

impl !UnwindSafe for AsyncLogger

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> IntoResult<T> for 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.