Remove emit_event! macro

This commit is contained in:
link2xt
2021-09-05 17:15:58 +00:00
parent 40fe65716f
commit 02a1abc0d5
8 changed files with 57 additions and 96 deletions

View File

@@ -13,7 +13,7 @@ macro_rules! info {
file = file!(),
line = line!(),
msg = &formatted);
emit_event!($ctx, $crate::EventType::Info(full));
$ctx.emit_event($crate::EventType::Info(full));
}};
}
@@ -28,7 +28,7 @@ macro_rules! warn {
file = file!(),
line = line!(),
msg = &formatted);
emit_event!($ctx, $crate::EventType::Warning(full));
$ctx.emit_event($crate::EventType::Warning(full));
}};
}
@@ -39,17 +39,10 @@ macro_rules! error {
};
($ctx:expr, $msg:expr, $($args:expr),* $(,)?) => {{
let formatted = format!($msg, $($args),*);
emit_event!($ctx, $crate::EventType::Error(formatted));
$ctx.emit_event($crate::EventType::Error(formatted));
}};
}
#[macro_export]
macro_rules! emit_event {
($ctx:expr, $event:expr) => {
$ctx.emit_event($event);
};
}
pub trait LogExt<T, E>
where
Self: std::marker::Sized,
@@ -136,7 +129,7 @@ impl<T, E: std::fmt::Display> LogExt<T, E> for Result<T, E> {
);
// We can't use the warn!() macro here as the file!() and line!() macros
// don't work with #[track_caller]
emit_event!(context, crate::EventType::Warning(full));
context.emit_event(crate::EventType::Warning(full));
};
self
}