Skip to content

Commit

Permalink
up fastdate version
Browse files Browse the repository at this point in the history
  • Loading branch information
zhuxiujia committed Oct 19, 2023
1 parent 96b884e commit 09375ef
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 26 deletions.
18 changes: 0 additions & 18 deletions src/plugin/file_split.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,24 +126,6 @@ pub trait Packer: Send + Sync {
new_log_name = first_file_path.trim_end_matches(&file_name).to_string() + &new_log_name;
return new_log_name;
}

fn log_name_parse_time(&self, file_name: &str, temp_name: &str) -> Result<DateTime, LogError> {
let file_name = file_name.extract_file_name();
let temp_name = temp_name.trim_end_matches(&format!(".{}", self.pack_name()));
if file_name.starts_with(&temp_name) {
let mut time_str = file_name.trim_start_matches(&temp_name).to_string();
if let Some(v) = time_str.rfind(".") {
time_str = time_str[0..v].to_string();
}
let time = DateTime::parse("YYYY-MM-DDThh:mm:ss.000000", &time_str);
return time.map_err(|e| LogError::from(e.to_string()));
} else {
return Err(LogError::E(format!(
"file_name={} not an pack file",
file_name
)));
}
}
}

/// split log file allow pack compress log
Expand Down
8 changes: 0 additions & 8 deletions tests/split_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,6 @@ mod test {
let _ = remove_dir_all("target/test/");
}

#[test]
fn test_parse_log_name() {
let t = LogPacker {}
.log_name_parse_time("temp2023-07-20T10-13-17.452247.log", "temp.log")
.unwrap();
assert_eq!(t.to_string(), "2023-07-20 10:13:17.452247");
}

#[test]
fn test_log_name_create() {
let p = LogPacker {};
Expand Down

0 comments on commit 09375ef

Please sign in to comment.