Enum flexi_logger::Criterion[][src]

pub enum Criterion {
    Size(u64),
    Age(Age),
    AgeOrSize(Ageu64),
}
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 Linux 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 linux, for different reasons.

To minimize the impact on age-based file-rotation, flexi_logger uses on Windows and linux its initialization time rather than the real file property 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.

Issue on Linux

std::fs::metadata.created() returns Err, because linux does not maintain a created-at-timestamp.

AgeOrSize(Ageu64)

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

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

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

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.