Struct fern::Panic

source ·
pub struct Panic;
Expand description

Logger which will panic whenever anything is logged. The panic will be exactly the message of the log.

Panic is useful primarily as a secondary logger, filtered by warning or error.

Examples

This configuration will output all messages to stdout and panic if an Error message is sent.

fern::Dispatch::new()
    // format, etc.
    .chain(std::io::stdout())
    .chain(
        fern::Dispatch::new()
            .level(log::LevelFilter::Error)
            .chain(fern::Panic),
    )
    .apply()?;

This sets up a “panic on warn+” logger, and ignores errors so it can be called multiple times.

This might be useful in test setup, for example, to disallow warn-level messages.

fn setup_panic_logging() {
    fern::Dispatch::new()
        .level(log::LevelFilter::Warn)
        .chain(fern::Panic)
        .apply()
        // ignore errors from setting up logging twice
        .ok();
}

Trait Implementations§

source§

impl From<Panic> for Output

source§

fn from(_: Panic) -> Self

Creates an output logger which will panic with message text for all messages.

Auto Trait Implementations§

§

impl RefUnwindSafe for Panic

§

impl Send for Panic

§

impl Sync for Panic

§

impl Unpin for Panic

§

impl UnwindSafe for Panic

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.