use sentry_core::protocol::Event;
use sentry_core::{Breadcrumb, Level};
pub fn convert_log_level(level: log::Level) -> Level {
match level {
log::Level::Error => Level::Error,
log::Level::Warn => Level::Warning,
log::Level::Info => Level::Info,
log::Level::Debug | log::Level::Trace => Level::Debug,
}
}
pub fn breadcrumb_from_record(record: &log::Record<'_>) -> Breadcrumb {
Breadcrumb {
ty: "log".into(),
level: convert_log_level(record.level()),
category: Some(record.target().into()),
message: Some(record.args().to_string()),
..Default::default()
}
}
pub fn event_from_record(record: &log::Record<'_>) -> Event<'static> {
Event {
logger: Some(record.target().into()),
level: convert_log_level(record.level()),
message: Some(record.args().to_string()),
..Default::default()
}
}
pub fn exception_from_record(record: &log::Record<'_>) -> Event<'static> {
event_from_record(record)
}