[][src]Struct spirit_log::background::FlushGuard

pub struct FlushGuard;

This, when dropped, flushes the logger.

Unless the logger is flushed, there's a risk of losing messages on application termination.

It can be used either separately or plugged into the spirit Builder (through the Extension trait). In that case, it also turns on the autojoin_bg_thread option, so the application actually waits for the spirit thread to terminate and drops the guard.

Note that it's fine to flush the logs multiple times (it only costs some performance, because the flush needs to wait for all the queued messages to be written).

Examples

Spirit::<Empty, Empty>::new()
    .with_singleton(FlushGuard)
    .run(|_spirit| {
        info!("Hello world");
        Ok(())
    });

Implementations

impl FlushGuard[src]

pub fn flush()[src]

Performs the flush of the global logger.

This can be used directly, instead of getting an instance of the FlushGuard and dropping it. But both ways have the same effect.

Trait Implementations

impl Drop for FlushGuard[src]

impl<E> Extension<E> for FlushGuard where
    E: Extensible<Ok = E>, 
[src]

Auto Trait Implementations

impl RefUnwindSafe for FlushGuard

impl Send for FlushGuard

impl Sync for FlushGuard

impl Unpin for FlushGuard

impl UnwindSafe for FlushGuard

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<B, F, R> Extension<B> for F where
    F: FnOnce(B) -> R,
    R: IntoResult<B>, 
[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.