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: impl AsRef<str>) -> Self
pub fn backend_url(self, url: impl AsRef<str>) -> Self
Controls where reports are sent to.
Set this to point to the backend server url of your choice.
This should be the base url of the Don’t Panic Server including the protocol without a
trailing slash. Eg. https://dontpanic.example.com or http://127.0.0.1:8080
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.