Skip to content

Commit

Permalink
fix loop
Browse files Browse the repository at this point in the history
  • Loading branch information
zhuxiujia committed May 21, 2022
1 parent b5d33dc commit df72718
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/plugin/file_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,17 @@ pub struct FileLoopAppender {
impl FileLoopAppender {
pub fn new(log_file_path: &str, max_temp_size: LogSize) -> FileLoopAppender {
Self {
file: FileSplitAppender::new(log_file_path, max_temp_size, RollingType::KeepNum(0), Box::new(LogPacker {}))
file: FileSplitAppender::new(log_file_path, max_temp_size, RollingType::KeepNum(1), Box::new(LogPacker {}))
}
}
}

impl LogAppender for FileLoopAppender {
fn do_logs(&self, records: &[FastLogRecord]) {
self.file.do_logs(records);
}
fn do_log(&self, record: &FastLogRecord) {
self.file.do_log(record);
//nothing to do
}
fn flush(&self) {
self.file.flush();
Expand Down
2 changes: 1 addition & 1 deletion src/plugin/file_split.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ impl RollingType {
RollingType::KeepNum(n) => {
let paths_vec = self.read_paths(dir, temp_name);
for index in 0..paths_vec.len() {
if index >= *n as usize {
if index >= (*n) as usize {
let item = &paths_vec[index];
std::fs::remove_file(item.path());
}
Expand Down

0 comments on commit df72718

Please sign in to comment.