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: UpkeepHow 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
impl Rotation
Sourcepub fn by_age(
age: Age,
use_last_time: bool,
time_fmt: &'static str,
max_time: Option<TimeDelta>,
) -> Self
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
Sourcepub fn by_age_and_size(
age: Age,
size_limit: u64,
use_last_time: bool,
time_fmt: &'static str,
max_time: Option<TimeDelta>,
) -> Self
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
Sourcepub fn compress_exclude(self, un_compress_files: usize) -> Self
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.
Sourcepub fn archive_dir<P: Into<PathBuf>>(self, archive_dir: P) -> Self
pub fn archive_dir<P: Into<PathBuf>>(self, archive_dir: P) -> Self
Move the old logs into an archive_dir.