pub struct Init<'a, TEmitter: Emitter + ?Sized = DefaultEmitter, TCtxt: Ctxt + ?Sized = DefaultCtxt> { /* private fields */ }
Expand description
The result of calling Setup::init
.
This type is a handle to an initialized runtime that can be used to ensure it’s fully flushed with a call to Init::blocking_flush
before your application exits.
Implementations§
Source§impl<'a, TEmitter: Emitter + ?Sized, TCtxt: Ctxt + ?Sized> Init<'a, TEmitter, TCtxt>
impl<'a, TEmitter: Emitter + ?Sized, TCtxt: Ctxt + ?Sized> Init<'a, TEmitter, TCtxt>
Sourcepub fn emitter(&self) -> &'a TEmitter
pub fn emitter(&self) -> &'a TEmitter
Get a reference to the initialized Emitter
.
Sourcepub fn get(&self) -> &'a AmbientRuntime<'a>
pub fn get(&self) -> &'a AmbientRuntime<'a>
Get the underlying runtime that was initialized.
Sourcepub fn blocking_flush(&self, timeout: Duration) -> bool
pub fn blocking_flush(&self, timeout: Duration) -> bool
Flush the runtime, ensuring all diagnostic events are fully processed.
This method forwards to Emitter::blocking_flush
, which has details on how the timeout is handled.
Sourcepub fn flush_on_drop(self, timeout: Duration) -> InitGuard<'a, TEmitter, TCtxt>
pub fn flush_on_drop(self, timeout: Duration) -> InitGuard<'a, TEmitter, TCtxt>
Flush the runtime when the returned guard is dropped, ensuring all diagnostic events are fully processed.
This method forwards to Emitter::blocking_flush
, which has details on how the timeout is handled.
Important: Ensure you bind an identifier to this method, otherwise it will be immediately dropped instead of at the end of your main
:
fn main() {
// Use an ident like `_guard`, not `_`
let _guard = emit::setup().init().flush_on_drop(Duration::from_secs(5));
// Your code goes here
}