pub struct AppendTimestamp {
    pub format: &'static str,
    pub file_limit: FileLimit,
    pub date_from: DateFrom,
}
Expand description

Append current timestamp as suffix when rotating files. If the timestamp already exists, an additional number is appended.

Current limitations:

  • Neither format nor the base filename can include the character ".".
  • The format should ensure that the lexical and chronological orderings are the same

Fields§

§format: &'static str

The format of the timestamp suffix

§file_limit: FileLimit

The file limit, e.g. when to delete an old file - by age (given by suffix) or by number of files

§date_from: DateFrom

Add timestamp from DateFrom

Implementations§

source§

impl AppendTimestamp

source

pub fn default(file_limit: FileLimit) -> Self

With format "%Y%m%dT%H%M%S"

source

pub fn with_format( format: &'static str, file_limit: FileLimit, date_from: DateFrom ) -> Self

Create new AppendTimestamp suffix scheme

Trait Implementations§

source§

impl SuffixScheme for AppendTimestamp

§

type Repr = TimestampSuffix

The representation of suffixes that this suffix scheme uses. E.g. if the suffix is a number, you can use usize.
source§

fn rotate_file( &mut self, _basepath: &Path, newest_suffix: Option<&TimestampSuffix>, suffix: &Option<TimestampSuffix> ) -> Result<TimestampSuffix>

file-rotate calls this function when the file at suffix needs to be rotated, and moves the log file accordingly. Thus, this function should not move any files itself. Read more
source§

fn parse(&self, suffix: &str) -> Option<Self::Repr>

Parse suffix from string.
source§

fn too_old(&self, suffix: &TimestampSuffix, file_number: usize) -> bool

Whether either the suffix or the chronological file number indicates that the file is old and should be deleted, depending of course on the file limit. file_number starts at 0 for the most recent suffix.
source§

fn scan_suffixes(&self, basepath: &Path) -> BTreeSet<SuffixInfo<Self::Repr>>

Find all files in the basepath.parent() directory that has path equal to basepath + a valid suffix. Return sorted collection - sorted from most recent to oldest based on the Ord implementation of Self::Repr.

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere 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 Twhere 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.