6 releases (3 breaking)

new 0.22.0 Jan 13, 2021
0.21.0 Nov 12, 2020
0.20.1 Sep 15, 2020
0.19.1 Aug 28, 2020
0.19.0 Jun 18, 2020

#347 in Debugging

Download history 1158/week @ 2020-09-25 1294/week @ 2020-10-02 1532/week @ 2020-10-09 1444/week @ 2020-10-16 1279/week @ 2020-10-23 1498/week @ 2020-10-30 1689/week @ 2020-11-06 2234/week @ 2020-11-13 2012/week @ 2020-11-20 1045/week @ 2020-11-27 1090/week @ 2020-12-04 1228/week @ 2020-12-11 929/week @ 2020-12-18 486/week @ 2020-12-25 1326/week @ 2021-01-01 2177/week @ 2021-01-08

5,999 downloads per month
Used in 4 crates (2 directly)

Apache-2.0

115KB
2K SLoC

Sentry Rust SDK: sentry-log

Adds support for automatic Breadcrumb and Event capturing from logs.

The log crate is supported in two ways. First, logs can be captured as breadcrumbs for later. Secondly, error logs can be captured as events to Sentry. By default anything above Info is recorded as breadcrumb and anything above Error is captured as error event.

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,
});

Resources

License: Apache-2.0

Dependencies

~3.5–4.5MB
~109K SLoC