pub trait Logger: 'static + Send + Sync {
    fn log(&self, level: Level, message: Message);
}
Expand description

Trait to help pass data to Options::set_logger.

Examples

struct Log {
    logged: AtomicUsize,
};

impl Logger for Log {
    fn log(&self, level: Level, message: Message) {
        self.logged.fetch_add(1, Ordering::SeqCst);
        println!("[{}]: {}", level, message);
    }
}

let mut options = Options::new();
options.set_logger(Log {
    logged: AtomicUsize::new(0),
});
let _shutdown = options.init()?;

Required methods

Logger callback.

Notes

The caller of this function will catch any unwinding panics and abort if any occured.

Examples
struct Log {
    logged: AtomicUsize,
};

impl Logger for Log {
    fn log(&self, level: Level, message: Message) {
        self.logged.fetch_add(1, Ordering::SeqCst);
        println!("[{}]: {}", level, message);
    }
}

Implementors