This commit is contained in:
Robin Appelman 2024-07-25 23:11:23 +02:00
commit b5be612307
3 changed files with 20 additions and 21 deletions

View file

@ -58,24 +58,23 @@ impl Matcher {
} }
for (i, log_match) in self.matches.iter().enumerate() { for (i, log_match) in self.matches.iter().enumerate() {
if log_match.has_meaningful_message { if log_match.has_meaningful_message
if log.level.matches(log_match.level) && log.level.matches(log_match.level)
&& log_match.pattern.is_match(log.message.as_str()) && log_match.pattern.is_match(log.message.as_str())
&& log_match.pattern_length >= best_length && log_match.pattern_length >= best_length
{ {
if log_match.pattern_length > best_length { if log_match.pattern_length > best_length {
best_match = None; best_match = None;
best_length = log_match.pattern_length; best_length = log_match.pattern_length;
}
best_match = Some(match best_match {
Some(MatchResult::Single(res)) => MatchResult::List(vec![res, i]),
Some(MatchResult::List(mut list)) => {
list.push(i);
MatchResult::List(list)
}
None => MatchResult::Single(i),
});
} }
best_match = Some(match best_match {
Some(MatchResult::Single(res)) => MatchResult::List(vec![res, i]),
Some(MatchResult::List(mut list)) => {
list.push(i);
MatchResult::List(list)
}
None => MatchResult::Single(i),
});
} }
} }
@ -129,7 +128,7 @@ impl Display for MatchResultDisplay<'_> {
if i > 0 { if i > 0 {
write!(f, " or ")?; write!(f, " or ")?;
} }
write!(f, "{statement}\n")?; writeln!(f, "{statement}")?;
} }
} }
Ok(()) Ok(())

View file

@ -29,11 +29,11 @@ pub fn match_list(app: &App) -> Table {
Constraint::Min(10), Constraint::Min(10),
]; ];
let all = log_row(&app.all, &app, "All lines"); let all = log_row(&app.all, app, "All lines");
let unmatched = if app.unmatched.lines.is_empty() { let unmatched = if app.unmatched.lines.is_empty() {
Either::Right(empty()) Either::Right(empty())
} else { } else {
Either::Left(once(log_row(&app.unmatched, &app, "Unmatched lines"))) Either::Left(once(log_row(&app.unmatched, app, "Unmatched lines")))
}; };
Table::new( Table::new(

View file

@ -26,7 +26,7 @@ pub fn raw_logs(app: &App, lines: &[usize]) -> Table<'static> {
Constraint::Percentage(100), Constraint::Percentage(100),
Constraint::Length(27), Constraint::Length(27),
]; ];
let table = Table::new(lines.map(|line| log_row(line)), widths) let table = Table::new(lines.map(log_row), widths)
.header(header) .header(header)
.highlight_style(TABLE_SELECTED_STYLE) .highlight_style(TABLE_SELECTED_STYLE)
.highlight_spacing(HighlightSpacing::Always); .highlight_spacing(HighlightSpacing::Always);