1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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)
}