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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
//! Adds support for automatic Breadcrumb, Event, and Log capturing from `log` records.
//!
//! The `log` crate is supported in three ways:
//! - Records can be captured as Sentry events. These are grouped and show up in the Sentry
//! [issues](https://docs.sentry.io/product/issues/) page, representing high severity issues to be
//! acted upon.
//! - Records can be captured as [breadcrumbs](https://docs.sentry.io/product/issues/issue-details/breadcrumbs/).
//! Breadcrumbs create a trail of what happened prior to an event, and are therefore sent only when
//! an event is captured, either manually through e.g. `sentry::capture_message` or through integrations
//! (e.g. the panic integration is enabled (default) and a panic happens).
//! - Records can be captured as traditional [logs](https://docs.sentry.io/product/explore/logs/)
//! Logs can be viewed and queried in the Logs explorer.
//!
//! By default anything at or above `Info` is recorded as a breadcrumb and
//! anything at or above `Error` is captured as error event.
//! Additionally, if the `sentry` crate is used with the `logs` feature flag, anything at or above `Info`
//! is captured as a [Structured Log](https://docs.sentry.io/product/explore/logs/).
//!
//! # Examples
//!
//! ```
//! let mut log_builder = pretty_env_logger::formatted_builder();
//! log_builder.parse_filters("info");
//! let logger = sentry_log::SentryLogger::with_dest(log_builder.build());
//!
//! log::set_boxed_logger(Box::new(logger)).unwrap();
//! log::set_max_level(log::LevelFilter::Info);
//!
//! let _sentry = sentry::init(());
//!
//! log::info!("Generates a breadcrumb");
//! log::error!("Generates an event");
//! ```
//!
//! Or one might also set an explicit filter, to customize how to treat log
//! records:
//!
//! ```
//! use sentry_log::LogFilter;
//!
//! let logger = sentry_log::SentryLogger::new().filter(|md| match md.level() {
//! log::Level::Error => LogFilter::Event,
//! _ => LogFilter::Ignore,
//! });
//! ```
//!
//! # Sending multiple items to Sentry
//!
//! To map a log record to multiple items in Sentry, you can combine multiple log filters
//! using the bitwise or operator:
//!
//! ```
//! use sentry_log::LogFilter;
//!
//! let logger = sentry_log::SentryLogger::new().filter(|md| match md.level() {
//! log::Level::Error => LogFilter::Event,
//! log::Level::Warn => LogFilter::Breadcrumb | LogFilter::Log,
//! _ => LogFilter::Ignore,
//! });
//! ```
//!
//! If you're using a custom record mapper instead of a filter, you can return a `Vec<RecordMapping>`
//! from your mapper function to send multiple items to Sentry from a single log record:
//!
//! ```
//! use sentry_log::{RecordMapping, SentryLogger, event_from_record, breadcrumb_from_record};
//!
//! let logger = SentryLogger::new().mapper(|record| {
//! match record.level() {
//! log::Level::Error => {
//! // Send both an event and a breadcrumb for errors
//! vec![
//! RecordMapping::Event(event_from_record(record)),
//! RecordMapping::Breadcrumb(breadcrumb_from_record(record)),
//! ]
//! }
//! log::Level::Warn => RecordMapping::Breadcrumb(breadcrumb_from_record(record)).into(),
//! _ => RecordMapping::Ignore.into(),
//! }
//! });
//! ```
pub use *;
pub use *;