pub enum Criterion {
    Size(u64),
    Age(Age),
    AgeOrSize(Age, u64),
}
Expand description

Criterion when to rotate the log file.

Used in Logger::rotate.

Variants§

§

Size(u64)

Rotate the log file when it exceeds the specified size in bytes.

§

Age(Age)

Rotate the log file when it has become older than the specified age.

§Minor limitation
§TL,DR

the combination of Logger::append() with Criterion::Age works OK, but not perfectly correct on Windows or unix when the program is restarted.

§Details

Applying the age criterion works fine while your program is running. Ideally, we should also apply it to the rCURRENT file when the program is restarted and you chose the Logger::append() option.

Unfortunately, this does not work on Windows, and it does not work on unix, for different reasons.

To minimize the impact on age-based file-rotation, flexi_logger uses on Windows, and on all other platforms where the creation date of a file is not available (like on Unix), the last modification date (or, if this is also not available, the current time stamp) as the created_at-info of an rCURRENT file that already exists, and the current timestamp when file rotation happens during further execution. Consequently, a left-over rCURRENT file from a previous program run will look newer than it is, and will be used longer than it should be.

§Issue on Windows

For compatibility with DOS (sic!), Windows magically transfers the created_at-info of a file that is deleted (or renamed) to its successor, when the recreation happens within some seconds [1].

If the file property were used by flexi_logger, the rCURRENT file would always appear to be as old as the first one that ever was created - rotation by time would completely fail.

[1] https://superuser.com/questions/966490/windows-7-what-is-date-created-file-property-referring-to.

§

AgeOrSize(Age, u64)

Rotate the file when it has either become older than the specified age, or when it has exceeded the specified size in bytes.

See documentation for Age and Size.

Trait Implementations§

source§

impl Clone for Criterion

source§

fn clone(&self) -> Criterion

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Criterion

source§

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

Formats the value using the given formatter. Read more
source§

impl Copy for Criterion

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

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more