improve exception display
All checks were successful
CI / build (push) Successful in 53s
CI / checks (push) Successful in 1m6s
CI / build-nixpkgs (push) Successful in 35s

This commit is contained in:
Robin Appelman 2025-06-11 17:16:30 +02:00
commit 7516cdcb7c
2 changed files with 28 additions and 15 deletions

View file

@ -14,7 +14,7 @@ regex = "1.11.1"
clap = { version = "4.5.30", features = ["derive"] } clap = { version = "4.5.30", features = ["derive"] }
logsmash-data = { version = "0.1.0", path = "./data" } logsmash-data = { version = "0.1.0", path = "./data" }
itertools = "0.14.0" itertools = "0.14.0"
ratatui = "0.29.0" ratatui = { version = "0.29.0", features = ["unstable-rendered-line-info"] }
tinystr = { version = "0.8.0", features = ["serde"] } tinystr = { version = "0.8.0", features = ["serde"] }
time = { version = "0.3.37", features = ["serde", "serde-well-known", "parsing", "macros"] } time = { version = "0.3.37", features = ["serde", "serde-well-known", "parsing", "macros"] }
hdrhistogram = "7.5.4" hdrhistogram = "7.5.4"

View file

@ -3,6 +3,7 @@ use crate::ui::style::TABLE_HEADER_STYLE;
use crate::ui::table::{ScrollbarTable, ScrollbarTableState}; use crate::ui::table::{ScrollbarTable, ScrollbarTableState};
use ratatui::prelude::*; use ratatui::prelude::*;
use ratatui::widgets::{Cell, Paragraph, Row, Wrap}; use ratatui::widgets::{Cell, Paragraph, Row, Wrap};
use std::fmt::Write;
use std::iter::once; use std::iter::once;
pub fn single_log(line: &FullLogLine) -> SingleLog { pub fn single_log(line: &FullLogLine) -> SingleLog {
@ -52,11 +53,7 @@ impl StatefulWidget for SingleLog<'_> {
let layout = Layout::default() let layout = Layout::default()
.direction(Direction::Vertical) .direction(Direction::Vertical)
.constraints(vec![ .constraints(vec![Constraint::Min(7), Constraint::Percentage(100)])
Constraint::Min(7),
Constraint::Min(5),
Constraint::Percentage(100),
])
.split(area); .split(area);
par.render(layout[0], buf); par.render(layout[0], buf);
@ -65,20 +62,36 @@ impl StatefulWidget for SingleLog<'_> {
if line.message.contains(&exception.message) { if line.message.contains(&exception.message) {
StatefulWidget::render( StatefulWidget::render(
render_exception(exception, self.path_prefix_length), render_exception(exception, self.path_prefix_length),
layout[1].union(layout[2]), layout[1],
buf, buf,
state, state,
); );
} else { } else {
let ex_par = Paragraph::new(format!( let mut text = format!("\n{}:\n {}", exception.exception, exception.message);
"\n{}:\n {}", let mut cur = exception;
exception.exception, exception.message while let Some(previous) = cur.previous.as_deref() {
)) write!(
.wrap(Wrap::default()); &mut text,
ex_par.render(layout[1], buf); "\n\nCaused by {}\n {}",
previous.exception, previous.message
)
.unwrap();
cur = previous;
}
let ex_par = Paragraph::new(text).wrap(Wrap::default());
let ex_layout = Layout::default()
.direction(Direction::Vertical)
.constraints(vec![
Constraint::Min(ex_par.line_count(layout[1].width) as u16 + 1),
Constraint::Percentage(100),
])
.split(layout[1]);
ex_par.render(ex_layout[0], buf);
StatefulWidget::render( StatefulWidget::render(
render_exception(exception, self.path_prefix_length), render_exception(exception, self.path_prefix_length),
layout[2], ex_layout[1],
buf, buf,
state, state,
); );
@ -123,7 +136,7 @@ fn exception_trace(
.unwrap_or_default(), .unwrap_or_default(),
), ),
Text::from(exception.line.to_string()).alignment(Alignment::Right), Text::from(exception.line.to_string()).alignment(Alignment::Right),
Text::from(""), Text::from(format!("new {}", exception.exception)),
]) ])
.style(TABLE_HEADER_STYLE); .style(TABLE_HEADER_STYLE);
let trace_rows = exception let trace_rows = exception