mirror of
https://codeberg.org/icewind/logsmash.git
synced 2026-06-03 10:04:12 +02:00
don't store match group lines twice
This commit is contained in:
parent
c1200c5676
commit
2f3e2325df
5 changed files with 10 additions and 13 deletions
15
src/app.rs
15
src/app.rs
|
|
@ -19,11 +19,7 @@ pub struct App<'a> {
|
|||
|
||||
impl<'a> App<'a> {
|
||||
pub fn match_lines(&self) -> usize {
|
||||
let unmatched_line_count = if self.unmatched.lines.is_empty() {
|
||||
0
|
||||
} else {
|
||||
1
|
||||
};
|
||||
let unmatched_line_count = if self.unmatched.count == 0 { 0 } else { 1 };
|
||||
self.matches.len() + 1 + unmatched_line_count
|
||||
}
|
||||
|
||||
|
|
@ -45,7 +41,7 @@ impl<'a> App<'a> {
|
|||
|
||||
pub struct LogMatch {
|
||||
pub result: Option<MatchResult>,
|
||||
pub lines: Vec<usize>,
|
||||
pub count: usize,
|
||||
pub histogram: TimeGraph,
|
||||
pub sparkline: String,
|
||||
pub all: GroupedLines,
|
||||
|
|
@ -60,17 +56,18 @@ impl LogMatch {
|
|||
for line in lines.iter().map(|line| &all_lines[*line]) {
|
||||
histogram.add(line.time);
|
||||
}
|
||||
let count = lines.len();
|
||||
let grouped = group_lines(all_lines, lines.iter().copied());
|
||||
let sparkline = histogram.sparkline::<10>();
|
||||
let all = GroupedLines {
|
||||
sparkline: sparkline.clone(),
|
||||
histogram: histogram.clone(),
|
||||
lines: lines.clone(),
|
||||
lines,
|
||||
};
|
||||
|
||||
LogMatch {
|
||||
result,
|
||||
lines,
|
||||
count,
|
||||
histogram,
|
||||
sparkline,
|
||||
grouped,
|
||||
|
|
@ -116,7 +113,7 @@ impl LogMatch {
|
|||
|
||||
impl LogMatch {
|
||||
pub fn count(&self) -> usize {
|
||||
self.lines.len()
|
||||
self.count
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -117,7 +117,7 @@ fn main() -> MainResult {
|
|||
});
|
||||
|
||||
let mut error_lines = Vec::with_capacity(32);
|
||||
let mut parsed_lines = Vec::with_capacity(1024);
|
||||
let mut parsed_lines = Vec::with_capacity(results.len());
|
||||
let mut unmatched_lines = Vec::with_capacity(256);
|
||||
|
||||
let mut parsed_index = 0;
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ pub fn footer<'a>(app: &App<'a>, params: FooterParams<'a>) -> Table<'a> {
|
|||
Table::new(
|
||||
[Row::new([
|
||||
Text::from(help(page)),
|
||||
Text::from(format!("{} unmatched items", app.unmatched.lines.len())),
|
||||
Text::from(format!("{} unmatched items", app.unmatched.count())),
|
||||
Text::from(format!("{} parse errors", app.error_count)),
|
||||
])],
|
||||
widths,
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ pub fn match_list<'a>(app: &'a App<'a>, filter: &Filter) -> ScrollbarTable<'a> {
|
|||
];
|
||||
|
||||
let all = log_row(&app.all, app, "All lines");
|
||||
let unmatched = if app.unmatched.lines.is_empty() {
|
||||
let unmatched = if app.unmatched.count() == 0 {
|
||||
Either::Right(empty())
|
||||
} else {
|
||||
Either::Left(once(log_row(&app.unmatched, app, "Unmatched lines")))
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ pub fn grouped_lines<'a>(
|
|||
Text::from(""),
|
||||
Text::from(""),
|
||||
Text::from(log_match.sparkline.as_str()),
|
||||
Text::from(log_match.lines.len().to_string()),
|
||||
Text::from(log_match.count().to_string()),
|
||||
]))
|
||||
.chain(
|
||||
grouped
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue