Skip to content

Commit

Permalink
add impl CanPack
Browse files Browse the repository at this point in the history
  • Loading branch information
zhuxiujia committed Jul 28, 2024
1 parent 30859e5 commit fd7cee2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
4 changes: 4 additions & 0 deletions src/plugin/file_split.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,10 @@ impl FileSplitAppender {
let _ = self.file.truncate();
self.temp_bytes.store(0, Ordering::SeqCst);
}

pub fn temp_name(&self) ->&str{
&self.temp_name
}
}

///log data pack
Expand Down
9 changes: 1 addition & 8 deletions tests/split_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,13 @@ mod test {
now: SystemTime::now(),
formated: "".to_string(),
}]);
appender.send_pack(format!("{}",DateTime::now()),None);
appender.send_pack(appender.temp_name().replace(".log", &DateTime::now().format("YYYY-MM-DDThh-mm-ss.000000.log")), None);
sleep(Duration::from_secs(1));
let rolling_num = RollingType::KeepNum(0).do_keep("target/test/", "temp.log");
assert_eq!(rolling_num, 1);
let _ = remove_dir_all("target/test/");
}

#[test]
fn test_log_name_create() {
let p = LogPacker {};
let name = p.new_data_log_name("temp.log", DateTime::now());
println!("{}", name);
assert_eq!(name.ends_with(".log"), true);
}

#[test]
fn test_extract_file_name() {
Expand Down

0 comments on commit fd7cee2

Please sign in to comment.