Struct sloggers::file::FileLoggerBuilder
source · pub struct FileLoggerBuilder { /* private fields */ }
Expand description
A logger builder which build loggers that write log records to the specified file.
The resulting logger will work asynchronously (the default channel size is 1024).
Implementations§
source§impl FileLoggerBuilder
impl FileLoggerBuilder
sourcepub fn new<P: AsRef<Path>>(path: P) -> Self
pub fn new<P: AsRef<Path>>(path: P) -> Self
Makes a new FileLoggerBuilder
instance.
This builder will create a logger which uses path
as
the output destination of the log records.
sourcepub fn source_location(&mut self, source_location: SourceLocation) -> &mut Self
pub fn source_location(&mut self, source_location: SourceLocation) -> &mut Self
Sets the source code location type this logger will use.
sourcepub fn overflow_strategy(
&mut self,
overflow_strategy: OverflowStrategy
) -> &mut Self
pub fn overflow_strategy( &mut self, overflow_strategy: OverflowStrategy ) -> &mut Self
Sets the overflow strategy for the logger.
sourcepub fn timezone(&mut self, timezone: TimeZone) -> &mut Self
pub fn timezone(&mut self, timezone: TimeZone) -> &mut Self
Sets the time zone which this logger will use.
sourcepub fn channel_size(&mut self, channel_size: usize) -> &mut Self
pub fn channel_size(&mut self, channel_size: usize) -> &mut Self
Sets the size of the asynchronous channel of this logger.
sourcepub fn kvfilter(&mut self, parameters: KVFilterParameters) -> &mut Self
pub fn kvfilter(&mut self, parameters: KVFilterParameters) -> &mut Self
Sets KVFilter
.
sourcepub fn truncate(&mut self) -> &mut Self
pub fn truncate(&mut self) -> &mut Self
By default, logger just appends log messages to file. If this method called, logger truncates the file to 0 length when opening.
sourcepub fn rotate_size(&mut self, size: u64) -> &mut Self
pub fn rotate_size(&mut self, size: u64) -> &mut Self
Sets the threshold used for determining whether rotate the current log file.
If the byte size of the current log file exceeds this value, the file will be rotated.
The name of the rotated file will be "${ORIGINAL_FILE_NAME}.0"
.
If there is a previously rotated file,
it will be renamed to "${ORIGINAL_FILE_NAME}.1"
before rotation of the current log file.
This process is iterated recursively until log file names no longer conflict or
rotate_keep
limit reached.
The default value is std::u64::MAX
.
sourcepub fn rotate_keep(&mut self, count: usize) -> &mut Self
pub fn rotate_keep(&mut self, count: usize) -> &mut Self
Sets the maximum number of rotated log files to keep.
If the number of rotated log files exceed this value, the oldest log file will be deleted.
The default value is 8
.
sourcepub fn rotate_compress(&mut self, compress: bool) -> &mut Self
pub fn rotate_compress(&mut self, compress: bool) -> &mut Self
Sets whether to compress or not compress rotated files.
If true
is specified, rotated files will be compressed by GZIP algorithm and
the suffix “.gz” will be appended to those file names.
The default value is false
.
sourcepub fn restrict_permissions(&mut self, restrict: bool) -> &mut Self
pub fn restrict_permissions(&mut self, restrict: bool) -> &mut Self
Sets whether the log files should have restricted permissions.
If true
is specified, new log files will be created with the 600
octal permission
on unix systems.
On Windows systems, new log files will have an ACL which just contains the SID of
the owner.
The default value is false
.