Struct RotatingFileSinkBuilder

Source
pub struct RotatingFileSinkBuilder<ArgBP, ArgRP> { /* private fields */ }
Expand description

§

§Note

The generics here are designed to check for required fields at compile time, users should not specify them manually and/or depend on them. If the generic concrete types or the number of generic types are changed in the future, it may not be considered as a breaking change.

Implementations§

Source§

impl<ArgBP, ArgRP> RotatingFileSinkBuilder<ArgBP, ArgRP>

Source

pub fn base_path<P>( self, base_path: P, ) -> RotatingFileSinkBuilder<PathBuf, ArgRP>
where P: Into<PathBuf>,

Specifies the base path of the log file.

The path needs to be suffixed with an extension, if you expect the rotated eventual file names to contain the extension.

If there is an extension, the different rotation policies will insert relevant information in the front of the extension. If there is not an extension, it will be appended to the end.

Supposes the given base path is /path/to/base_file.log, the eventual file names may look like the following:

  • /path/to/base_file_1.log
  • /path/to/base_file_2.log
  • /path/to/base_file_2022-03-23.log
  • /path/to/base_file_2022-03-24.log
  • /path/to/base_file_2022-03-23_03.log
  • /path/to/base_file_2022-03-23_04.log

This parameter is required.

Source

pub fn rotation_policy( self, rotation_policy: RotationPolicy, ) -> RotatingFileSinkBuilder<ArgBP, RotationPolicy>

Specifies the rotation policy.

This parameter is required.

Source

pub fn max_files(self, max_files: usize) -> Self

Specifies the maximum number of files.

If the number of existing files reaches this parameter, the oldest file will be deleted on the next rotation.

Specify 0 for no limit.

This parameter is optional.

Source

pub fn rotate_on_open(self, rotate_on_open: bool) -> Self

Specifies whether to rotate files once when constructing RotatingFileSink.

For the RotationPolicy::Daily, RotationPolicy::Hourly, and RotationPolicy::Period rotation policies, it may truncate the contents of the existing file if the parameter is true, since the file name is a time point and not an index.

This parameter is optional.

Source

pub fn level_filter(self, level_filter: LevelFilter) -> Self

Specifies a log level filter.

This parameter is optional.

Source

pub fn formatter(self, formatter: Box<dyn Formatter>) -> Self

Specifies a formatter.

This parameter is optional.

Source

pub fn error_handler(self, handler: ErrorHandler) -> Self

Specifies an error handler.

This parameter is optional.

Source§

impl RotatingFileSinkBuilder<PathBuf, RotationPolicy>

Source

pub fn build(self) -> Result<RotatingFileSink>

Builds a RotatingFileSink.

§Error

If the argument rotation_policy is invalid, or an error occurs opening the file, Error::CreateDirectory or Error::OpenFile will be returned.

Auto Trait Implementations§

§

impl<ArgBP, ArgRP> Freeze for RotatingFileSinkBuilder<ArgBP, ArgRP>
where ArgBP: Freeze, ArgRP: Freeze,

§

impl<ArgBP, ArgRP> !RefUnwindSafe for RotatingFileSinkBuilder<ArgBP, ArgRP>

§

impl<ArgBP, ArgRP> Send for RotatingFileSinkBuilder<ArgBP, ArgRP>
where ArgBP: Send, ArgRP: Send,

§

impl<ArgBP, ArgRP> Sync for RotatingFileSinkBuilder<ArgBP, ArgRP>
where ArgBP: Sync, ArgRP: Sync,

§

impl<ArgBP, ArgRP> Unpin for RotatingFileSinkBuilder<ArgBP, ArgRP>
where ArgBP: Unpin, ArgRP: Unpin,

§

impl<ArgBP, ArgRP> !UnwindSafe for RotatingFileSinkBuilder<ArgBP, ArgRP>

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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

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

Source§

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>,

Source§

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.