Sentry Rust SDK: sentry-log
Adds support for automatic Breadcrumb, Event, and Log capturing from log records.
The log crate is supported in three ways:
- Records can be captured as Sentry events. These are grouped and show up in the Sentry issues page, representing high severity issues to be acted upon.
- Records can be captured as breadcrumbs.
Breadcrumbs create a trail of what happened prior to an event, and are therefore sent only when
an event is captured, either manually through e.g.
sentry::capture_messageor through integrations (e.g. the panic integration is enabled (default) and a panic happens). - Records can be captured as traditional logs Logs can be viewed and queried in the Logs explorer.
By default anything at or above Info is recorded as a breadcrumb and
anything at or above Error is captured as error event.
Additionally, if the sentry crate is used with the logs feature flag, anything at or above Info
is captured as a Structured Log.
Examples
let mut log_builder = formatted_builder;
log_builder.parse_filters;
let logger = with_dest;
set_boxed_logger.unwrap;
set_max_level;
let _sentry = init;
info!;
error!;
Or one might also set an explicit filter, to customize how to treat log records:
use LogFilter;
let logger = new.filter;
Sending multiple items to Sentry
To map a log record to multiple items in Sentry, you can combine multiple log filters using the bitwise or operator:
use LogFilter;
let logger = new.filter;
If you're using a custom record mapper instead of a filter, you can return a Vec<RecordMapping>
from your mapper function to send multiple items to Sentry from a single log record:
use ;
let logger = new.mapper;
Resources
License: MIT