better span view

This commit is contained in:
Jana Dönszelmann 2026-04-02 10:40:55 +02:00
parent 43e40b61e3
commit fdfc08e88b
No known key found for this signature in database
12 changed files with 612 additions and 206 deletions

View file

@ -6,7 +6,7 @@ use crate::tui::{
LogViewer,
input::{FieldMatcher, InputTarget},
},
model::LogEntry,
model::{FieldsName, LogEntry},
};
mod serialize_regex {
@ -55,19 +55,26 @@ impl MatcherValue {
#[derive(Serialize, Deserialize, Debug)]
pub enum Matcher {
Field { name: String, value: MatcherValue },
Message { value: MatcherValue },
Specific { hash: u64 },
Field {
span: FieldsName,
name: String,
value: MatcherValue,
},
Message {
value: MatcherValue,
},
Specific {
hash: u64,
},
}
impl Matcher {
pub fn matches(&self, entry: &LogEntry) -> bool {
match self {
Matcher::Specific { hash } => entry.hash() == *hash,
Matcher::Field { name, value } => entry
.all_fields()
.fields
.get(name)
Matcher::Field { span, name, value } => entry
.spans()
.find(span, name)
.is_some_and(|v| value.matches(v)),
Matcher::Message { value } => {
entry.message_or_name().is_some_and(|v| value.matches(&v))
@ -78,16 +85,20 @@ impl Matcher {
pub fn from_input(target: InputTarget, lv: &LogViewer) -> Option<Self> {
match target {
InputTarget::Fields(fm) => {
let value = lv.footer_fields().get(lv.footer_list.selected?)?.clone();
let (span, name, value) = lv.get_selected_field()?;
Some(Self::Field {
name: value.0,
value: MatcherValue::from_field_matcher(fm?, Some(value.1))?,
span,
name,
value: MatcherValue::from_field_matcher(fm?, Some(value))?,
})
}
InputTarget::Text(fm) => Some(Self::Message {
value: MatcherValue::from_field_matcher(
fm,
lv.selected().and_then(|(i, _)| i.message_or_name()),
lv.selected()
.as_ref()
.and_then(|(i, _)| i.message_or_name())
.map(|i| i.to_string()),
)?,
}),
InputTarget::This => {