36 releases

new 0.35.0 Nov 29, 2024
0.34.0 Jun 5, 2024
0.33.0 May 27, 2024
0.32.2 Jan 30, 2024
0.19.0 Jun 18, 2020

#733 in Debugging

Download history 8065/week @ 2024-08-16 8525/week @ 2024-08-23 8732/week @ 2024-08-30 7506/week @ 2024-09-06 7445/week @ 2024-09-13 7655/week @ 2024-09-20 6849/week @ 2024-09-27 9916/week @ 2024-10-04 6986/week @ 2024-10-11 7926/week @ 2024-10-18 8522/week @ 2024-10-25 8677/week @ 2024-11-01 11075/week @ 2024-11-08 10224/week @ 2024-11-15 7377/week @ 2024-11-22 6601/week @ 2024-11-29

36,969 downloads per month
Used in 15 crates (3 directly)

Apache-2.0

235KB
4.5K 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–5.5MB
~97K SLoC