"Error reading the log directory/files" always fires the first time
Bug Report
Version
0.2.5
Platform
All
Crates
tracing-appender
Description
The error Error reading the log directory/files: No such file or directory (os error 2) is always printed on first use, when the log directory doesn't exist yet.
This happens when using the RollingFileAppender with max_files set, because prune_old_logs is called when max_files has a value, without taking into account if this is the first or nth time that gets executed.
The following snippet should help reproducing the error.
let file_appender = RollingFileAppender::builder()
.rotation(Rotation::DAILY)
.max_log_files(1)
.filename_suffix("suffix".to_string())
.build("some_folder");I would expect this error not to appear for the first time, given that the folders won't exist. A possible solution would be to not send any message to stderr when the folder doesn't exist. That means the error would never appear when the folder doesn't exist. Doesn't mind if it's the 1st or nth execution.
Source: tokio-rs/tracing