pub struct Builder { /* private fields */ }Expand description
A builder to configure dontpanic behavior.
Use the builder method in to root of this crate to create this type.
Implementations§
source§impl Builder
impl Builder
sourcepub fn environment(self, name: impl Into<String>) -> Self
pub fn environment(self, name: impl Into<String>) -> Self
Set the reported environment. Useful for separating reports originating on dev and staging environments from production reports. You can use debug_assertions to set this, or environment variables set by a CI pipeline.
use anyhow::Result;
fn main() -> Result<()> {
dontpanic::builder("<PROJECT_API_KEY>")
.environment(if cfg!(debug_assertions) {
"development"
} else {
"production"
})
.build()?;
Ok(())
}sourcepub fn version(self, version: impl Into<String>) -> Self
pub fn version(self, version: impl Into<String>) -> Self
Set your application version. Use this to track when a panic! or error! first occurred and consequently, when it is resolved.
If application version tracking is done via Cargo.toml, the current version can be obtained via CARGO_PKG_VERSION env var:
fn main() -> Result<()> {
dontpanic::builder("<PROJECT_API_KEY>")
.version(env!("CARGO_PKG_VERSION"))
.build()?;
Ok(())
}sourcepub fn backend_url(self, url: String) -> Self
pub fn backend_url(self, url: String) -> Self
Controls where reports are sent to.
Set this to point to the backend server url where you want to send reports. For more information see Don’t Panic Server documentation.
sourcepub fn send_report_on_log_errors(self, enabled: bool) -> Self
Available on crate features tracing and log only.
pub fn send_report_on_log_errors(self, enabled: bool) -> Self
tracing and log only.Enabled by default. log::error!, tracing::error! and tracing::event!(Level::ERROR, ... will trigger a report to be sent to the configured backend server.