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

pub struct FlushGuard;
Expand description

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

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

Executes the destructor for this type. Read more

Perform the transformation on the given extensible. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

Turns self into the result.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.