mirror of
https://codeberg.org/icewind/logsmash.git
synced 2026-06-03 10:04:12 +02:00
improve exception display
This commit is contained in:
parent
ff5efa9eac
commit
7516cdcb7c
2 changed files with 28 additions and 15 deletions
|
|
@ -14,7 +14,7 @@ regex = "1.11.1"
|
|||
clap = { version = "4.5.30", features = ["derive"] }
|
||||
logsmash-data = { version = "0.1.0", path = "./data" }
|
||||
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"] }
|
||||
time = { version = "0.3.37", features = ["serde", "serde-well-known", "parsing", "macros"] }
|
||||
hdrhistogram = "7.5.4"
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ use crate::ui::style::TABLE_HEADER_STYLE;
|
|||
use crate::ui::table::{ScrollbarTable, ScrollbarTableState};
|
||||
use ratatui::prelude::*;
|
||||
use ratatui::widgets::{Cell, Paragraph, Row, Wrap};
|
||||
use std::fmt::Write;
|
||||
use std::iter::once;
|
||||
|
||||
pub fn single_log(line: &FullLogLine) -> SingleLog {
|
||||
|
|
@ -52,11 +53,7 @@ impl StatefulWidget for SingleLog<'_> {
|
|||
|
||||
let layout = Layout::default()
|
||||
.direction(Direction::Vertical)
|
||||
.constraints(vec![
|
||||
Constraint::Min(7),
|
||||
Constraint::Min(5),
|
||||
Constraint::Percentage(100),
|
||||
])
|
||||
.constraints(vec![Constraint::Min(7), Constraint::Percentage(100)])
|
||||
.split(area);
|
||||
|
||||
par.render(layout[0], buf);
|
||||
|
|
@ -65,20 +62,36 @@ impl StatefulWidget for SingleLog<'_> {
|
|||
if line.message.contains(&exception.message) {
|
||||
StatefulWidget::render(
|
||||
render_exception(exception, self.path_prefix_length),
|
||||
layout[1].union(layout[2]),
|
||||
layout[1],
|
||||
buf,
|
||||
state,
|
||||
);
|
||||
} else {
|
||||
let ex_par = Paragraph::new(format!(
|
||||
"\n{}:\n {}",
|
||||
exception.exception, exception.message
|
||||
))
|
||||
.wrap(Wrap::default());
|
||||
ex_par.render(layout[1], buf);
|
||||
let mut text = format!("\n{}:\n {}", exception.exception, exception.message);
|
||||
let mut cur = exception;
|
||||
while let Some(previous) = cur.previous.as_deref() {
|
||||
write!(
|
||||
&mut text,
|
||||
"\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(
|
||||
render_exception(exception, self.path_prefix_length),
|
||||
layout[2],
|
||||
ex_layout[1],
|
||||
buf,
|
||||
state,
|
||||
);
|
||||
|
|
@ -123,7 +136,7 @@ fn exception_trace(
|
|||
.unwrap_or_default(),
|
||||
),
|
||||
Text::from(exception.line.to_string()).alignment(Alignment::Right),
|
||||
Text::from(""),
|
||||
Text::from(format!("new {}", exception.exception)),
|
||||
])
|
||||
.style(TABLE_HEADER_STYLE);
|
||||
let trace_rows = exception
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue