The recommended pattern for setting up emit is currently:
fn main() {
let rt = emit::setup().emit_to(..).init();
..
rt.blocking_flush(Duration::from_secs(5));
}
If the main function panics, then there's no guarantee events will be flushed. Generally, I think you should avoid doing too much in Drop, but we should add a guard type you can use to try flush, even if the main function panics:
fn main() {
let _ = emit::setup().emit_to(..).init().flush_on_drop(Duration::from_secs(5));
..
}
Alternatively, we could also make the type returned by init() try flush unconditionally on Drop, but it would be hard to pick the right duration to block for that works for everyone.
The recommended pattern for setting up
emit
is currently:If the
main
function panics, then there's no guarantee events will be flushed. Generally, I think you should avoid doing too much inDrop
, but we should add a guard type you can use to try flush, even if the main function panics:Alternatively, we could also make the type returned by
init()
try flush unconditionally onDrop
, but it would be hard to pick the right duration to block for that works for everyone.