mirror of
https://codeberg.org/icewind/logsmash.git
synced 2026-06-03 10:04:12 +02:00
improve displaying messages with tabs and newlines
This commit is contained in:
parent
8f0e443275
commit
9724fb31a5
3 changed files with 30 additions and 6 deletions
|
|
@ -173,9 +173,9 @@ impl<'a> LogLine<'a> {
|
||||||
Cow::Owned(format!(
|
Cow::Owned(format!(
|
||||||
"{}{}{}({}) - {} line {}",
|
"{}{}{}({}) - {} line {}",
|
||||||
if self.message.starts_with("Exception thrown:") {
|
if self.message.starts_with("Exception thrown:") {
|
||||||
""
|
Cow::Borrowed("")
|
||||||
} else {
|
} else {
|
||||||
&self.message
|
self.cleaned_message_single_line()
|
||||||
},
|
},
|
||||||
if self.message.starts_with("Exception thrown:") {
|
if self.message.starts_with("Exception thrown:") {
|
||||||
""
|
""
|
||||||
|
|
@ -188,7 +188,7 @@ impl<'a> LogLine<'a> {
|
||||||
exception.line
|
exception.line
|
||||||
))
|
))
|
||||||
} else {
|
} else {
|
||||||
Cow::Borrowed(&self.message)
|
self.cleaned_message_single_line()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -212,6 +212,26 @@ impl<'a> LogLine<'a> {
|
||||||
|| filter_part.is_match(self.user.as_str())
|
|| filter_part.is_match(self.user.as_str())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn cleaned_message(&self) -> Cow<str> {
|
||||||
|
clean_log_message(&self.message)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn cleaned_message_single_line(&self) -> Cow<str> {
|
||||||
|
if self.message.contains('\t') || self.message.contains('\n') {
|
||||||
|
Cow::Owned(self.message.replace(['\t', '\n'], " "))
|
||||||
|
} else {
|
||||||
|
Cow::Borrowed(self.message.as_ref())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn clean_log_message(message: &str) -> Cow<str> {
|
||||||
|
if message.contains('\t') {
|
||||||
|
Cow::Owned(message.replace('\t', " "))
|
||||||
|
} else {
|
||||||
|
Cow::Borrowed(message)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(
|
#[derive(
|
||||||
|
|
@ -279,6 +299,10 @@ impl FullLogLine {
|
||||||
.map(|(key, value)| (key.as_str(), value.as_str()))
|
.map(|(key, value)| (key.as_str(), value.as_str()))
|
||||||
.filter(|(key, _)| *key != "app")
|
.filter(|(key, _)| *key != "app")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn cleaned_message(&self) -> Cow<str> {
|
||||||
|
clean_log_message(&self.message)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize, Debug, Clone)]
|
#[derive(Deserialize, Debug, Clone)]
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,7 @@ impl StatefulWidget for DistinctLogs<'_> {
|
||||||
.map(|e| e.exception.as_ref())
|
.map(|e| e.exception.as_ref())
|
||||||
.unwrap_or_default(),
|
.unwrap_or_default(),
|
||||||
if line.exception.is_some() { ":\n" } else { "" },
|
if line.exception.is_some() { ":\n" } else { "" },
|
||||||
line.message,
|
line.cleaned_message(),
|
||||||
line.level.as_str(),
|
line.level.as_str(),
|
||||||
line.app,
|
line.app,
|
||||||
line.version,
|
line.version,
|
||||||
|
|
@ -143,7 +143,7 @@ fn log_row<'a>(line: &'a LogLine<'a>, grouping: DistinctLogGrouping, is_in_view:
|
||||||
DistinctLogGrouping::Request => Row::new([
|
DistinctLogGrouping::Request => Row::new([
|
||||||
Text::from(line.level.as_str()),
|
Text::from(line.level.as_str()),
|
||||||
Text::from(line.app.as_ref()),
|
Text::from(line.app.as_ref()),
|
||||||
Text::from(line.message.as_ref()),
|
Text::from(line.cleaned_message_single_line()),
|
||||||
Text::from(""),
|
Text::from(""),
|
||||||
Text::from(format_time(line.time)).alignment(Alignment::Right),
|
Text::from(format_time(line.time)).alignment(Alignment::Right),
|
||||||
]),
|
]),
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ impl StatefulWidget for SingleLog<'_> {
|
||||||
let line = self.line;
|
let line = self.line;
|
||||||
let par = Paragraph::new(format!(
|
let par = Paragraph::new(format!(
|
||||||
"{}\n\n {} {}\n {}\n\n {} from {} by {} at {} - Nextcloud {}",
|
"{}\n\n {} {}\n {}\n\n {} from {} by {} at {} - Nextcloud {}",
|
||||||
line.message,
|
line.cleaned_message(),
|
||||||
line.method,
|
line.method,
|
||||||
line.url,
|
line.url,
|
||||||
line.user_agent,
|
line.user_agent,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue