pub struct Config {
pub appends: SyncVec<Mutex<Box<dyn LogAppender>>>,
pub level: LevelFilter,
pub filters: SyncVec<Box<dyn Filter>>,
pub format: Box<dyn RecordFormat>,
pub chan_len: Option<usize>,
}
Expand description
the fast_log Config for example:
use fast_log::Config;
fn main(){
fast_log::init(Config::new().console().chan_len(Some(1000000))).unwrap();
}
Fields§
§appends: SyncVec<Mutex<Box<dyn LogAppender>>>
Each appender is responsible for printing its own business every LogAppender have one thread(need Mutex) access this.
level: LevelFilter
the log level filter
filters: SyncVec<Box<dyn Filter>>
filter log
format: Box<dyn RecordFormat>
format record into field fast_log_record’s formatted:String
chan_len: Option<usize>
the channel length,default None(Unbounded channel)
Implementations§
source§impl Config
impl Config
pub fn new() -> Self
sourcepub fn level(self, level: LevelFilter) -> Self
pub fn level(self, level: LevelFilter) -> Self
set log LevelFilter
sourcepub fn add_filter<F: Filter + 'static>(self, filter: F) -> Self
pub fn add_filter<F: Filter + 'static>(self, filter: F) -> Self
add log Filter
sourcepub fn format<F: RecordFormat + 'static>(self, format: F) -> Self
pub fn format<F: RecordFormat + 'static>(self, format: F) -> Self
set log format
sourcepub fn file_split<R: CanRollingPack + 'static, K: Keep + 'static, P: Packer + Sync + 'static>(
self,
file_path: &str,
rolling: R,
keeper: K,
packer: P,
) -> Self
pub fn file_split<R: CanRollingPack + 'static, K: Keep + 'static, P: Packer + Sync + 'static>( self, file_path: &str, rolling: R, keeper: K, packer: P, ) -> Self
add a FileSplitAppender
sourcepub fn split<F: SplitFile + 'static, R: Keep + 'static, P: Packer + Sync + 'static, H: CanRollingPack + 'static>(
self,
file_path: &str,
keeper: R,
packer: P,
how_pack: H,
) -> Self
pub fn split<F: SplitFile + 'static, R: Keep + 'static, P: Packer + Sync + 'static, H: CanRollingPack + 'static>( self, file_path: &str, keeper: R, packer: P, how_pack: H, ) -> Self
add a SplitAppender .split::<FileType, Packer>() for example:
use fast_log::Config;
use fast_log::consts::LogSize;
use fast_log::plugin::file_split::{Rolling, RawFile, RollingType, KeepType};
use fast_log::plugin::packer::LogPacker;
fn new(){
fast_log::init(
Config::new()
.chan_len(Some(100000))
.split::<RawFile, _, _, _>(
"target/logs/temp.log",
KeepType::All,
LogPacker {},
Rolling::new(RollingType::BySize(LogSize::MB(1))),
),
);
}
sourcepub fn custom<Appender: LogAppender + 'static>(self, arg: Appender) -> Self
pub fn custom<Appender: LogAppender + 'static>(self, arg: Appender) -> Self
add a custom LogAppender
sourcepub fn add_appender<Appender: LogAppender + 'static>(
self,
arg: Appender,
) -> Self
pub fn add_appender<Appender: LogAppender + 'static>( self, arg: Appender, ) -> Self
add a LogAppender
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Config
impl !RefUnwindSafe for Config
impl Send for Config
impl Sync for Config
impl Unpin for Config
impl !UnwindSafe for Config
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