Skip to main content

ErrorHandler

Type Alias ErrorHandler 

Source
pub type ErrorHandler = Arc<dyn Fn(&Error) + Send + Sync>;
Available on crate feature std only.
Expand description

Callback invoked for every sink error, flush error, and message formatting error the logger encounters.

The handler runs on the thread that logged the record. If the handler itself logs through a logger whose sink keeps failing, the nested failures are not reported again (a per-thread guard prevents unbounded recursion), but the nested records are still dispatched.

§Examples

use std::sync::Arc;
use log_io::{ErrorHandler, Logger};

let handler: ErrorHandler = Arc::new(|err| eprintln!("logging failed: {err}"));
let logger = Logger::builder().stderr_logfmt().on_error(handler).build();

Aliased Type§

pub struct ErrorHandler { /* private fields */ }