oopsie-core 0.1.0-rc.14

Core error types and trace capture for the oopsie error-handling library
Documentation
//! `tracing` integration helpers.

use tracing_error::ErrorLayer;
use tracing_subscriber::fmt::format;
use tracing_subscriber::registry::LookupSpan;

/// Construct a `tracing_error::ErrorLayer` configured to format span fields
/// as JSON.
///
/// Equivalent to `ErrorLayer::new(JsonFields::default())` but doesn't require
/// the caller to depend on `tracing-subscriber` directly.
#[cfg(feature = "serde")]
#[inline]
#[must_use]
pub fn json_error_layer<S>() -> ErrorLayer<S, format::JsonFields>
where
    S: tracing::Subscriber + for<'span> LookupSpan<'span>,
{
    ErrorLayer::new(format::JsonFields::default())
}

/// Construct a `tracing_error::ErrorLayer` configured to format span fields using
/// the default format (i.e. `Debug`-formatting each field value).
#[inline]
#[must_use]
pub fn default_error_layer<S>() -> ErrorLayer<S, format::DefaultFields>
where
    S: tracing::Subscriber + for<'span> LookupSpan<'span>,
{
    ErrorLayer::new(format::DefaultFields::new())
}