fix lifetime issues with event macro

This commit is contained in:
Eliza Weisman 2018-09-27 15:41:52 -07:00
parent e54b294de2
commit cfabda9aa4
No known key found for this signature in database
GPG Key ID: F9C1A595C3814436

View File

@ -130,14 +130,15 @@ macro_rules! span {
macro_rules! event {
(target: $target:expr, $lvl:expr, { $($k:ident = $val:expr),* }, $($arg:tt)+ ) => ({
{ let field_values: &[& dyn $crate::Value] = &[ $( & $val),* ];
$crate::Event {
use $crate::Subscriber;
$crate::Dispatcher::current().observe_event(&$crate::Event {
timestamp: ::std::time::Instant::now(),
parent: $crate::Span::current(),
follows_from: &[],
meta: &static_meta!(@ $target, $lvl, $($k),* ),
field_values: &field_values[..],
message: format_args!( $($arg)+ ),
};
});
}
});
@ -259,12 +260,6 @@ impl<'event, 'meta: 'event> Event<'event, 'meta> {
}
}
impl<'event, 'meta> Drop for Event<'event, 'meta> {
fn drop(&mut self) {
Dispatcher::current().observe_event(self);
}
}
// ===== impl Span =====
impl Span {