Struct fern::Panic
[−]
[src]
pub struct Panic;
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 function sets up a "panic on warn+" logger, and ignores the error if it has been set up before. One could call this in test functions, for example, to error on warn-level messages.
fn setup_panic_logging() { fern::Dispatch::new() .level(log::LevelFilter::Warn) .chain(fern::Panic) .apply() .ok(); // ignore result - it's ok if we try to set this up multiple times }