mirror of
https://codeberg.org/icewind/logsmash.git
synced 2026-06-03 18:14:11 +02:00
handle files that start with an invalid line
This commit is contained in:
parent
87d904f7c5
commit
b30003b304
1 changed files with 3 additions and 9 deletions
10
src/main.rs
10
src/main.rs
|
|
@ -69,16 +69,10 @@ fn main() -> MainResult {
|
|||
let lines: Vec<_> = log_file.iter().enumerate().collect();
|
||||
|
||||
let mut counts: HashMap<MatchResult, Vec<usize>> = HashMap::new();
|
||||
let (_, first) = lines.first().copied().unwrap_or_default();
|
||||
let first_parsed = match parse_line(first) {
|
||||
Ok(first_parsed) => first_parsed,
|
||||
Err(e) => {
|
||||
eprintln!("Failed to parse the first line in the log: {:#}", e);
|
||||
eprintln!("{first}");
|
||||
let Some(first_parsed) = lines.iter().find_map(|(_, line)| parse_line(line).ok()) else {
|
||||
eprintln!("Failed to find at least one log line that parses successfully");
|
||||
return Ok(());
|
||||
}
|
||||
};
|
||||
|
||||
let server_version = first_parsed.version;
|
||||
let statements = get_statements(
|
||||
once(SourceDefinition {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue