pub struct CrashReporter(/* private fields */);Expand description
Cheap cloneable handle to the installed crash reporter.
Implementations§
Source§impl CrashReporter
impl CrashReporter
Sourcepub fn install(options: CrashReporterOptions) -> Result<Self>
pub fn install(options: CrashReporterOptions) -> Result<Self>
Install the process-wide panic hook and, unless disabled, the native fatal-signal handler.
Installing twice is an error; use CrashReporter::current to reach the existing handle.
Sourcepub fn detached(options: CrashReporterOptions) -> Result<Self>
pub fn detached(options: CrashReporterOptions) -> Result<Self>
Build a reporter that owns its directory but installs no process-wide hooks.
Deterministic tests and secondary tools use this to exercise writing, retention, parsing, and upload without changing global process state.
Sourcepub fn current() -> Option<Self>
pub fn current() -> Option<Self>
The installed reporter, when CrashReporter::install has already succeeded.
Sourcepub fn max_reports(&self) -> usize
pub fn max_reports(&self) -> usize
Configured retention count.
Sourcepub fn max_report_bytes(&self) -> usize
pub fn max_report_bytes(&self) -> usize
Configured per-report byte limit.
Sourcepub fn add_extra_parameter(
&self,
key: impl Into<String>,
value: impl Into<String>,
) -> Result<()>
pub fn add_extra_parameter( &self, key: impl Into<String>, value: impl Into<String>, ) -> Result<()>
Add or replace one bounded extra parameter recorded in later reports.
Sourcepub fn remove_extra_parameter(&self, key: &str) -> bool
pub fn remove_extra_parameter(&self, key: &str) -> bool
Remove one extra parameter, reporting whether it was present.
Sourcepub fn extra_parameters(&self) -> BTreeMap<String, String>
pub fn extra_parameters(&self) -> BTreeMap<String, String>
A snapshot of the retained extra parameters.
Sourcepub fn capture_report(&self, report: &CrashReport) -> Result<PathBuf>
pub fn capture_report(&self, report: &CrashReport) -> Result<PathBuf>
Write one caller-built report atomically and apply retention.
Sourcepub fn last_crash_report(&self) -> Result<Option<CrashReport>>
pub fn last_crash_report(&self) -> Result<Option<CrashReport>>
The newest retained report, parsed from disk.
Sourcepub fn pending_reports(&self) -> Result<Vec<CrashReport>>
pub fn pending_reports(&self) -> Result<Vec<CrashReport>>
Every retained report in oldest-to-newest order, bounded by the configured retention.
Sourcepub fn delete_report(&self, id: &str) -> Result<bool>
pub fn delete_report(&self, id: &str) -> Result<bool>
Delete one retained report by identifier, reporting whether it existed.
Sourcepub fn upload_endpoint(&self) -> Option<&str>
pub fn upload_endpoint(&self) -> Option<&str>
The endpoint configured through CrashReporterOptions::upload_endpoint.
Sourcepub fn upload_body(report: &CrashReport) -> Result<Vec<u8>>
pub fn upload_body(report: &CrashReport) -> Result<Vec<u8>>
Build the exact JSON body one upload sends for a report.
Sourcepub fn upload_pending(&self, endpoint: &str) -> Result<UploadSummary>
pub fn upload_pending(&self, endpoint: &str) -> Result<UploadSummary>
POST every retained report to endpoint, deleting the ones the endpoint accepts.
At most MAX_CRASH_UPLOAD_REPORTS reports are sent per call. Reports the endpoint
rejects stay on disk for the next attempt.
Sourcepub fn build_report(
&self,
kind: CrashKind,
message: impl Into<String>,
) -> CrashReport
pub fn build_report( &self, kind: CrashKind, message: impl Into<String>, ) -> CrashReport
Build a report for the current process using the reporter’s identity and parameters.