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

source

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.

source

pub fn format(&mut self, format: Format) -> &mut Self

Sets the format of log records.

source

pub fn source_location(&mut self, source_location: SourceLocation) -> &mut Self

Sets the source code location type this logger will use.

source

pub fn overflow_strategy( &mut self, overflow_strategy: OverflowStrategy ) -> &mut Self

Sets the overflow strategy for the logger.

source

pub fn timezone(&mut self, timezone: TimeZone) -> &mut Self

Sets the time zone which this logger will use.

source

pub fn level(&mut self, severity: Severity) -> &mut Self

Sets the log level of this logger.

source

pub fn channel_size(&mut self, channel_size: usize) -> &mut Self

Sets the size of the asynchronous channel of this logger.

source

pub fn kvfilter(&mut self, parameters: KVFilterParameters) -> &mut Self

Sets KVFilter.

source

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.

source

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.

source

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.

source

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.

source

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.

Trait Implementations§

source§

impl Build for FileLoggerBuilder

source§

fn build(&self) -> Result<Logger>

Builds a logger.
source§

impl BuildWithCustomFormat for FileLoggerBuilder

§

type Decorator = FileLoggerDecorator

Decorator type generated by the logger builder.
source§

fn build_with_custom_format<F, D>(&self, f: F) -> Result<Logger>
where F: FnOnce(Self::Decorator) -> Result<D>, D: Drain + Send + 'static, D::Err: Debug,

Builds a logger with a custom format.
source§

impl Debug for FileLoggerBuilder

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.