sentry_log/lib.rs
1//! Adds support for automatic Breadcrumb and Event capturing from logs.
2//!
3//! The `log` crate is supported in two ways. First, logs can be captured as
4//! breadcrumbs for later. Secondly, error logs can be captured as events to
5//! Sentry. By default anything above `Info` is recorded as a breadcrumb and
6//! anything above `Error` is captured as error event.
7//!
8//! # Examples
9//!
10//! ```
11//! let mut log_builder = pretty_env_logger::formatted_builder();
12//! log_builder.parse_filters("info");
13//! let logger = sentry_log::SentryLogger::with_dest(log_builder.build());
14//!
15//! log::set_boxed_logger(Box::new(logger)).unwrap();
16//! log::set_max_level(log::LevelFilter::Info);
17//!
18//! let _sentry = sentry::init(());
19//!
20//! log::info!("Generates a breadcrumb");
21//! log::error!("Generates an event");
22//! ```
23//!
24//! Or one might also set an explicit filter, to customize how to treat log
25//! records:
26//!
27//! ```
28//! use sentry_log::LogFilter;
29//!
30//! let logger = sentry_log::SentryLogger::new().filter(|md| match md.level() {
31//! log::Level::Error => LogFilter::Event,
32//! _ => LogFilter::Ignore,
33//! });
34//! ```
35
36#![doc(html_favicon_url = "https://sentry-brand.storage.googleapis.com/favicon.ico")]
37#![doc(html_logo_url = "https://sentry-brand.storage.googleapis.com/sentry-glyph-black.png")]
38#![warn(missing_docs)]
39
40mod converters;
41mod logger;
42
43pub use converters::*;
44pub use logger::*;