Struct Rotation

Source
pub struct Rotation {
    pub by_age: Option<ByAge>,
    pub by_size: Option<u64>,
    pub time_fmt: Option<&'static str>,
    pub upkeep: Upkeep,
    pub archive_dir: Option<PathBuf>,
    pub compress_exclude: Option<usize>,
}
Expand description

Log rotation configuration.

by_age and by_size can be configured at the same time, means log will be rotate when any of the conditions met. It’s not valid when by_age and by_size both None.

Fields§

§by_age: Option<ByAge>§by_size: Option<u64>§time_fmt: Option<&'static str>

If None, archive in file.<number> form, and Upkeep::Age will be ignore.

If Some, archive in file.<datetime> form.

§upkeep: Upkeep

How to cleanup the old file

§archive_dir: Option<PathBuf>

Whether to move the log into an archive_dir. if not configured, it’s the same dir as current log.

§compress_exclude: Option<usize>

When Some(count), indicate how many uncompressed archived logs. When 0, all the archive logs are compressed. When None, do not compress archive logs;

Implementations§

Source§

impl Rotation

Source

pub fn by_size(size_limit: u64, max_files: Option<usize>) -> Self

Archive log when size is reached.

§Arguments:
  • max_files: When None, do not delete old files
Source

pub fn by_age( age: Age, use_last_time: bool, time_fmt: &'static str, max_time: Option<TimeDelta>, ) -> Self

Rotate log by time (Day/Hour)

§Arguments:
  • use_last_time: Similar to system’s log-rotate,

    • For Age::Day, the latest archive use yesterday’s timestamp;

    • For Age::Hour, use last hour’s timestamp.

  • time_fmt: timestamp format of the archived files

  • max_time: Delete archived logs older than the time

Source

pub fn by_age_and_size( age: Age, size_limit: u64, use_last_time: bool, time_fmt: &'static str, max_time: Option<TimeDelta>, ) -> Self

Rotate log when time (Day/Hour) is reached or when size is reached

§Arguments:
  • use_last_time: Similar to system’s log-rotate,

    • For Age::Day, the latest archive use yesterday’s timestamp;

    • For Age::Hour, use last hour’s timestamp.

  • time_fmt: timestamp format of the archived files

  • max_time: Delete archived logs older than the time

Source

pub fn compress_exclude(self, un_compress_files: usize) -> Self

Compress archived logs, with a number of recent files left uncompressed.

When un_compress_files == 0, means all files will be compressed.

Source

pub fn archive_dir<P: Into<PathBuf>>(self, archive_dir: P) -> Self

Move the old logs into an archive_dir.

Trait Implementations§

Source§

impl Hash for Rotation

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. 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> 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.