sentry-log

Crates.iosentry-log
lib.rssentry-log
version0.35.0
sourcesrc
created_at2020-06-18 13:47:41.963027
updated_at2024-11-29 09:29:14.300606
descriptionSentry integration for log and env_logger crates.
homepagehttps://sentry.io/welcome/
repositoryhttps://github.com/getsentry/sentry-rust
max_upload_size
id255340
size22,069
Sentry Bot (getsentry-bot)

documentation

README

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

Commit count: 1057

cargo fmt