35 releases

0.34.0 Jun 5, 2024
0.32.3 Apr 16, 2024
0.32.2 Jan 30, 2024
0.32.1 Dec 18, 2023
0.19.0 Jun 18, 2020

#740 in Debugging

Download history 9611/week @ 2024-02-21 9333/week @ 2024-02-28 9665/week @ 2024-03-06 10114/week @ 2024-03-13 11578/week @ 2024-03-20 9780/week @ 2024-03-27 8023/week @ 2024-04-03 10730/week @ 2024-04-10 8756/week @ 2024-04-17 8845/week @ 2024-04-24 6528/week @ 2024-05-01 7565/week @ 2024-05-08 8241/week @ 2024-05-15 8448/week @ 2024-05-22 7643/week @ 2024-05-29 6940/week @ 2024-06-05

32,713 downloads per month
Used in 12 crates (3 directly)

Apache-2.0

230KB
4K SLoC

Sentry

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 a 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

~4–5MB
~95K SLoC