Enum flexi_logger::Naming
source · pub enum Naming {
Timestamps,
TimestampsDirect,
TimestampsCustomFormat {
current_infix: Option<&'static str>,
format: &'static str,
},
Numbers,
NumbersDirect,
}
Expand description
The naming convention for rotated log files.
Common rule for all variants is that the names of the current output file and the rotated log files only differ in the infix.
See Logger::log_to_file
for a description of how the filename is built, including the infix.
See the variants for how the infix is used by them.
Used in Logger::rotate
.
Variants§
Timestamps
Logs are written to a file with infix rCURRENT
.
File rotation renames this file to a name with a timestamp-infix
like "r2023-01-27_14-41-08"
, logging continues with a fresh file with infix rCURRENT
.
If multiple rotations happen within the same second, extended infixes are used like
"r2023-01-27_14-41-08.restart-0001"
.
Same as
Naming::TimestampsCustomFormat {
current_infix: Some("rCURRENT"),
format: "r%Y-%m-%d_%H-%M-%S",
}
TimestampsDirect
Logs are written to a file with a timestamp-infix, like "r2023-01-27_14-41-08"
.
File rotation switches over to the next file.
If multiple rotations happen within the same second, extended infixes are used like
"r2023-01-27_14-41-08.restart-0001"
.
Same as
Naming::TimestampsCustomFormat {
current_infix: None,
format: "r%Y-%m-%d_%H-%M-%S",
}
TimestampsCustomFormat
Defines the infixes for the file to which the logs are written, and for the rotated files.
Fields
current_infix: Option<&'static str>
Controls if a special infix is used for the file to which the logs are currently written.
If Some(infix)
is given, then it is taken as static infix for the file
to which the logs are written.
File rotation renames this file to a file with a timestamp infix.
If this file already exists, an extended infix is used like
"2024-06-09.restart-0001"
.
If None
is given, then the logs will be directly written to a file with timestamp infix.
File rotation only switches over to a new file with a fresh timestamp infix.
If this file already exists, e.g. because rotation is triggered more frequently
than the timestamp varies (according to the pattern), then an extended infix is used like
"2024-06-09.restart-0001"
.
format: &'static str
The format of the timestamp infix.
See https://docs.rs/chrono/latest/chrono/format/strftime/index.html for a list of supported specifiers.
Make sure you use a format that is compatible to your file system(s).
Examples:
"%Y-%m-%d"
produces timestamp infixes like "2024-06-09"
.
"%Y-%m-%d_%H-%M-%S"
produces timestamp infixes like "2024-06-09_13-24-35"
.
Numbers
Logs are written to a file with infix rCURRENT
.
File rotation renames this file to a name with a number-infix
like "r00000"
, "r00001"
, etc.,
logging continues with a fresh file with infix rCURRENT
.
NumbersDirect
Logs are written to a file with a number-infix,
like "r00000"
, "r00001"
, etc.
File rotation switches over to the next file.