mirror of
https://codeberg.org/icewind/logsmash.git
synced 2026-06-03 18:14:11 +02:00
cleanup
This commit is contained in:
parent
b67cc99dbe
commit
e27a964457
1 changed files with 0 additions and 32 deletions
|
|
@ -2,7 +2,6 @@ use crate::logline::LogLine;
|
||||||
use itertools::Either;
|
use itertools::Either;
|
||||||
use logsmash_data::{LogLevel, LoggingStatement, StatementList};
|
use logsmash_data::{LogLevel, LoggingStatement, StatementList};
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
use std::fmt::{Display, Formatter};
|
|
||||||
use std::iter::once;
|
use std::iter::once;
|
||||||
|
|
||||||
pub struct LogMatch {
|
pub struct LogMatch {
|
||||||
|
|
@ -106,37 +105,6 @@ impl MatchResult {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct MatchResultDisplay<'a> {
|
|
||||||
log_statements: &'a StatementList,
|
|
||||||
result: &'a MatchResult,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Display for MatchResultDisplay<'_> {
|
|
||||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
|
||||||
match self.result {
|
|
||||||
MatchResult::Single(index) => {
|
|
||||||
if let Some(statement) = self.log_statements.get(*index) {
|
|
||||||
write!(f, "{statement}")
|
|
||||||
} else {
|
|
||||||
write!(f, "«unknown statement»")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
MatchResult::List(list) => {
|
|
||||||
// todo: max length
|
|
||||||
for (i, index) in list.iter().enumerate() {
|
|
||||||
if let Some(statement) = self.log_statements.get(*index) {
|
|
||||||
if i > 0 {
|
|
||||||
write!(f, " or ")?;
|
|
||||||
}
|
|
||||||
writeln!(f, "{statement}")?;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_matcher() {
|
fn test_matcher() {
|
||||||
use crate::logline::Exception;
|
use crate::logline::Exception;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue