Skip to content

Commit

Permalink
wrap the regex for detecting timestamp with lazy_static!
Browse files Browse the repository at this point in the history
  • Loading branch information
1toldyou committed Apr 17, 2024
1 parent d3cc7a4 commit 3e478d5
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/module/recorder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -480,9 +480,11 @@ impl YTAStatus {
// New versions of ytarchive prepend a timestamp to the output
// Sample line
// 2024/04/16 16:25:31
let timestamp_re = Regex::new(r"^\d{4}/\d{2}/\d{2} \d{2}:\d{2}:\d{2}")
.expect("Failed to compile regex for detecting yta output timestamp");
let line = if line.len() > 20 && timestamp_re.is_match(line) {
lazy_static! {
static ref TIMESTAMP_RE: Regex = Regex::new(r"^\d{4}/\d{2}/\d{2} \d{2}:\d{2}:\d{2}")
.expect("Failed to compile regex for detecting yta output timestamp");
}
let line = if line.len() > 20 && TIMESTAMP_RE.is_match(line) {
line[20..].trim()
} else {
line
Expand Down

0 comments on commit 3e478d5

Please sign in to comment.