Open zerolfx opened 3 months ago
Well, we could simply write it like this:
let created = metadata.created().ok().or(metadata.modified().ok())?;
or we could wait until https://github.com/rust-lang/rust/pull/125692 gets merged. (The build in the PR worked fine and it seems like it's going to get merged soon.) @mladedav or @davidbarsky what do you think?
I honestly don't know much about the appender.
Falling back to the modified timestamp seems better than just not deleting the files at all. But I wonder if we couldn't instead fall back to parsing the name since it should contain the creation time.
And whether there shouldn't be an infallible fallback at the end with UNIX_EPOCH
or something, just so we can be sure that whatever happens and even if the system/filesystem doesn't support even the modified timestamp, we delete some files instead of letting the logs grow without bounds. I'm not sure what's more important though, keeping the number of generated files from growing or keeping latest log files for at least as long as configured.
Falling back to the modified timestamp seems better than just not deleting the files at all. But I wonder if we couldn't instead fall back to parsing the name since it should contain the creation time.
That's actually a good idea. I think it's even better than using the modified time! With the modified time it could happen that some user manually checks the log files, accidentally modifies it and then it gets deleted on the next iteration. I'll submit a PR with this change!
And whether there shouldn't be an infallible fallback at the end with UNIX_EPOCH or something, just so we can be sure that whatever happens and even if the system/filesystem doesn't support even the modified timestamp, we delete some files instead of letting the logs grow without bounds. I'm not sure what's more important though, keeping the number of generated files from growing or keeping latest log files for at least as long as configured.
My personal view is that it's better to keep more files than promised than less :)
When compiled with
--target=x86_64-unknown-linux-musl
, log rotation doesn't work. That is caused by:Suggestion: Fallback to the modification time when the creation time cannot be retrieved. (Modification time is part of POSIX standard but creation time is not.)