Keep separators between time part of logfile names

The timestamp part of the log filename becomes a dense series of
numbers because sanitize_filename removes ":" as it is a special
character on windows.  So use a custom replacement character to fix
work around this.
This commit is contained in:
Floris Bruynooghe
2019-11-29 16:03:57 +01:00
parent de28ed68c9
commit 2c3cfc53c2

View File

@@ -70,7 +70,14 @@ impl Logger {
fn open(logdir: &Path) -> Result<(String, fs::File), io::Error> {
let basename =
chrono::offset::Utc::now().to_rfc3339_opts(chrono::SecondsFormat::Secs, true);
let mut fname = sanitize_filename::sanitize(format!("{}.log", &basename));
let mut fname = sanitize_filename::sanitize_with_options(
format!("{}.log", &basename),
sanitize_filename::Options {
truncate: true,
windows: true,
replacement: ".",
},
);
let mut counter = 0;
loop {
match std::fs::OpenOptions::new()