diff --git a/src/plugin/file_split.rs b/src/plugin/file_split.rs index 2448852..f77f00d 100644 --- a/src/plugin/file_split.rs +++ b/src/plugin/file_split.rs @@ -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 diff --git a/tests/split_test.rs b/tests/split_test.rs index c786436..6673e7b 100644 --- a/tests/split_test.rs +++ b/tests/split_test.rs @@ -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() {