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.