use flexi_logger::writers::LogWriter; use std::{ io::{Error, ErrorKind}, sync::{Arc, Mutex}, }; fn main() {} #[allow(dead_code)] struct MyWriter { file: Arc>, } impl LogWriter for MyWriter { fn write( &self, now: &mut flexi_logger::DeferredNow, record: &flexi_logger::Record, ) -> std::io::Result<()> { let mut file = self .file .lock() .map_err(|e| Error::new(ErrorKind::Other, e.to_string()))?; flexi_logger::default_format(&mut *file, now, record) } fn flush(&self) -> std::io::Result<()> { let mut file = self .file .lock() .map_err(|e| Error::new(ErrorKind::Other, e.to_string()))?; file.flush() } }