pub struct LogRawFile {
pub level: Level,
pub format: LogFormat,
pub file_path: Box<Path>,
}Expand description
Config for file sink that supports atomic append from multiprocess.
Used when you want a reliable log regardless of crash or killed. For log rotation, you need system log-rotate service to notify with signal.
§Example
Source of crate::recipe::raw_file_logger_custom()
use captains_log::*;
use std::path::{self, Path, PathBuf};
pub fn raw_file_logger_custom<P: Into<PathBuf>>(
file_path: P, max_level: Level, time_fmt: &'static str, format_func: FormatFunc,
) -> Builder {
let format = LogFormat::new(time_fmt, format_func);
let _file_path = file_path.into();
let p = path::absolute(&_file_path).expect("path convert to absolute");
let dir = p.parent().unwrap();
let file_name = Path::new(p.file_name().unwrap());
let file = LogRawFile::new(dir, file_name, max_level, format);
return Builder::default().signal(signal_hook::consts::SIGUSR1).add_sink(file);
}Fields§
§level: Levelmax log level in this file
format: LogFormat§file_path: Box<Path>path: dir/name
Implementations§
Source§impl LogRawFile
impl LogRawFile
Trait Implementations§
Source§impl Hash for LogRawFile
impl Hash for LogRawFile
Source§impl SinkConfigTrait for LogRawFile
impl SinkConfigTrait for LogRawFile
Auto Trait Implementations§
impl Freeze for LogRawFile
impl RefUnwindSafe for LogRawFile
impl Send for LogRawFile
impl Sync for LogRawFile
impl Unpin for LogRawFile
impl UnwindSafe for LogRawFile
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more