in proxy_agent_shared/src/logger/rolling_logger.rs [86:113]
fn archive_file(&self) -> Result<()> {
let new_file_name = self.get_current_file_full_path(Some(format!(
"{}-{}",
misc_helpers::get_date_time_string_with_milliseconds(),
misc_helpers::get_date_time_unix_nano()
)));
let current_name = self.get_current_file_full_path(None);
fs::rename(current_name, new_file_name)?;
let log_files = self.get_log_files()?;
// delete oldest files
let max_count: usize = self.max_log_file_count.into();
let file_count = log_files.len();
if file_count >= max_count {
let mut count = max_count;
for log in log_files {
fs::remove_file(log)?;
count += 1;
if count > file_count {
break;
}
}
}
Ok(())
}