mirror of
https://codeberg.org/icewind/logsmash.git
synced 2026-06-04 02:24:11 +02:00
borrowed line parsing
This commit is contained in:
parent
b9c7704699
commit
95e09f0e0c
12 changed files with 61 additions and 62 deletions
|
|
@ -5,7 +5,7 @@ use ratatui::layout::Constraint;
|
|||
use ratatui::text::Text;
|
||||
use ratatui::widgets::{Cell, Row};
|
||||
|
||||
pub fn error_list(app: &App) -> ScrollbarTable {
|
||||
pub fn error_list<'a>(app: &'a App<'a>) -> ScrollbarTable<'a> {
|
||||
let header = [Text::from("Error"), Text::from("Line")]
|
||||
.into_iter()
|
||||
.map(Cell::from)
|
||||
|
|
|
|||
|
|
@ -3,9 +3,10 @@ use crate::ui::state::UiPage;
|
|||
use ratatui::layout::Constraint;
|
||||
use ratatui::prelude::Style;
|
||||
use ratatui::style::palette::tailwind;
|
||||
use ratatui::text::Text;
|
||||
use ratatui::widgets::{Row, Table};
|
||||
|
||||
pub fn footer(app: &App, page: UiPage) -> Table {
|
||||
pub fn footer<'a>(app: &App<'a>, page: UiPage) -> Table<'a> {
|
||||
let footer_style = Style::default()
|
||||
.bg(tailwind::BLACK)
|
||||
.fg(tailwind::GREEN.c600);
|
||||
|
|
@ -18,9 +19,9 @@ pub fn footer(app: &App, page: UiPage) -> Table {
|
|||
|
||||
Table::new(
|
||||
[Row::new([
|
||||
help(page).to_string(),
|
||||
format!("{} unmatched items", app.unmatched.lines.len()),
|
||||
format!("{} parse errors", app.error_count),
|
||||
Text::from(help(page)),
|
||||
Text::from(format!("{} unmatched items", app.unmatched.lines.len())),
|
||||
Text::from(format!("{} parse errors", app.error_count)),
|
||||
])],
|
||||
widths,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ use ratatui::widgets::{Cell, Row};
|
|||
use std::fmt::Write;
|
||||
use std::iter::{empty, once};
|
||||
|
||||
pub fn match_list(app: &App) -> ScrollbarTable {
|
||||
pub fn match_list<'a>(app: &'a App<'a>) -> ScrollbarTable<'a> {
|
||||
let header = [
|
||||
Text::from("Statement"),
|
||||
Text::from("File"),
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ use ratatui::layout::{Alignment, Constraint};
|
|||
use ratatui::text::Text;
|
||||
use ratatui::widgets::{Cell, Row};
|
||||
|
||||
pub fn raw_logs<'a>(app: &'a App, lines: &[usize]) -> ScrollbarTable<'a> {
|
||||
pub fn raw_logs<'a>(app: &'a App<'a>, lines: &[usize]) -> ScrollbarTable<'a> {
|
||||
let lines = lines.iter().copied().map(|i| &app.lines[i]);
|
||||
let header = [
|
||||
Text::from("Level"),
|
||||
|
|
@ -29,10 +29,10 @@ pub fn raw_logs<'a>(app: &'a App, lines: &[usize]) -> ScrollbarTable<'a> {
|
|||
ScrollbarTable::new(lines.map(log_row), widths).header(header)
|
||||
}
|
||||
|
||||
fn log_row(line: &LogLine) -> Row {
|
||||
fn log_row<'a>(line: &'a LogLine<'a>) -> Row<'a> {
|
||||
Row::new([
|
||||
Text::from(line.level.as_str()),
|
||||
Text::from(line.app.as_str()),
|
||||
Text::from(line.app),
|
||||
Text::from(line.display()),
|
||||
Text::from(format_time(line.time)).alignment(Alignment::Right),
|
||||
])
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ use ratatui::layout::Constraint;
|
|||
use ratatui::text::Text;
|
||||
use ratatui::widgets::{Cell, Row};
|
||||
|
||||
pub fn grouped_lines<'a>(app: &'a App, log_match: &'a LogMatch) -> ScrollbarTable<'a> {
|
||||
pub fn grouped_lines<'a>(app: &'a App<'a>, log_match: &'a LogMatch) -> ScrollbarTable<'a> {
|
||||
let grouped = &log_match.grouped;
|
||||
let header = [
|
||||
Text::from("Level"),
|
||||
|
|
@ -35,7 +35,7 @@ fn group_row<'a>(app: &'a App, group: &'a GroupedLines) -> Row<'a> {
|
|||
|
||||
Row::new([
|
||||
Text::from(line.level.as_str()),
|
||||
Text::from(line.app.as_str()),
|
||||
Text::from(line.app),
|
||||
Text::from(line.display()),
|
||||
Text::from(group.sparkline.as_str()),
|
||||
Text::from(group.len().to_string()),
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ impl<'a> LogsState<'a> {
|
|||
#[derive(Clone)]
|
||||
pub struct LogState<'a> {
|
||||
pub trace_len: usize,
|
||||
pub log: &'a LogLine,
|
||||
pub log: &'a LogLine<'a>,
|
||||
pub full_line: FullLogLine,
|
||||
pub table_state: ScrollbarTableState,
|
||||
pub previous: Box<UiState<'a>>,
|
||||
|
|
@ -97,7 +97,7 @@ impl<'a> UiState<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn process(self, event: UiEvent, app: &'a App) -> (bool, UiState) {
|
||||
pub fn process(self, event: UiEvent, app: &'a App<'a>) -> (bool, UiState) {
|
||||
match (self, event) {
|
||||
(UiState::Quit, _) => (true, UiState::Quit),
|
||||
(_, UiEvent::Quit) => (true, UiState::Quit),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue