mirror of
https://codeberg.org/icewind/logsmash.git
synced 2026-06-03 10:04:12 +02:00
better log message
This commit is contained in:
parent
c66517a931
commit
adb370e6bb
9 changed files with 62 additions and 19 deletions
|
|
@ -31,10 +31,11 @@ If a log item cannot be matched to an origin it will added to the "Unmatched lin
|
|||
|
||||
Currently, the program can match against data from the following sources:
|
||||
|
||||
- Nextcloud server 29
|
||||
- Nextcloud server 24 - 29
|
||||
- files_accesscontrol 1.19.1
|
||||
- files_antivirus 5.5.7
|
||||
- deck: 1.13.1
|
||||
- calendar: 4.7.13
|
||||
|
||||
### Updating baked data
|
||||
|
||||
|
|
|
|||
|
|
@ -4,10 +4,11 @@ final: prev: let
|
|||
inherit (prev.lib) importJSON;
|
||||
inherit (prev.lib.lists) flatten;
|
||||
allPackages = importJSON ./versions.json;
|
||||
packages = {
|
||||
server = {"29" = allPackages.server."29";};
|
||||
inherit (allPackages) files_accesscontrol files_antivirus deck;
|
||||
};
|
||||
# packages = {
|
||||
# server = {"29" = allPackages.server."29";};
|
||||
# inherit (allPackages) files_accesscontrol files_antivirus deck;
|
||||
# };
|
||||
packages = allPackages;
|
||||
|
||||
loggingFor = mode: name:
|
||||
mapAttrs (major: data: (final.callPackage ./extracted-logs.nix {
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
makeRustPlatform,
|
||||
rust-bin,
|
||||
lib,
|
||||
extracted-logs-rust,
|
||||
}: let
|
||||
inherit (lib.sources) sourceByRegex;
|
||||
src = sourceByRegex ../. ["Cargo.*" "(src|data)(/.*)?"];
|
||||
|
|
@ -17,6 +18,11 @@ in
|
|||
|
||||
inherit src;
|
||||
|
||||
preBuild = ''
|
||||
rm -r data/src/data
|
||||
cp -r ${extracted-logs-rust} data/src/data
|
||||
'';
|
||||
|
||||
cargoLock = {
|
||||
lockFile = ../Cargo.lock;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -25,14 +25,47 @@ impl LogLine {
|
|||
.as_ref()
|
||||
.map(|e| e.exception.as_str())
|
||||
.hash(&mut hasher);
|
||||
self.exception
|
||||
.as_ref()
|
||||
.map(|e| e.file.as_str())
|
||||
.hash(&mut hasher);
|
||||
self.app.hash(&mut hasher);
|
||||
self.exception.as_ref().map(|e| e.line).hash(&mut hasher);
|
||||
self.app.hash(&mut hasher);
|
||||
hasher.finish()
|
||||
}
|
||||
}
|
||||
|
||||
impl LogLine {
|
||||
pub fn display(&self) -> String {
|
||||
if let Some(exception) = self.exception.as_ref() {
|
||||
format!(
|
||||
"{}{}{}({}) - {} line {}",
|
||||
if self.message.starts_with("Exception thrown:") {
|
||||
""
|
||||
} else {
|
||||
self.message.as_str()
|
||||
},
|
||||
if self.message.starts_with("Exception thrown:") {
|
||||
""
|
||||
} else {
|
||||
": "
|
||||
},
|
||||
exception.exception,
|
||||
exception.message,
|
||||
exception.file,
|
||||
exception.line
|
||||
)
|
||||
} else {
|
||||
self.message.clone()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug)]
|
||||
#[serde(rename_all = "PascalCase")]
|
||||
pub struct Exception {
|
||||
pub message: String,
|
||||
pub exception: String,
|
||||
pub file: String,
|
||||
pub line: usize,
|
||||
|
|
|
|||
13
src/main.rs
13
src/main.rs
|
|
@ -22,8 +22,6 @@ mod ui;
|
|||
#[derive(Debug, Parser)]
|
||||
struct Args {
|
||||
file: String,
|
||||
#[arg(long)]
|
||||
unmatched: bool,
|
||||
}
|
||||
|
||||
fn main() -> MainResult {
|
||||
|
|
@ -72,15 +70,10 @@ fn main() -> MainResult {
|
|||
};
|
||||
if let Some(index) = matcher.match_log(&parsed) {
|
||||
counts.entry(index).or_default().push(i);
|
||||
} else if let Some(entry) = unmatched_counts.get_mut(parsed.app.as_str()) {
|
||||
entry.push(i)
|
||||
} else {
|
||||
if args.unmatched && parsed.app != "PHP" {
|
||||
println!("{} :{:?}", parsed.message, &parsed.exception);
|
||||
}
|
||||
if let Some(entry) = unmatched_counts.get_mut(parsed.app.as_str()) {
|
||||
entry.push(i)
|
||||
} else {
|
||||
unmatched_lines.push(i);
|
||||
}
|
||||
unmatched_lines.push(i);
|
||||
}
|
||||
parsed_lines.push(parsed);
|
||||
i += 1;
|
||||
|
|
|
|||
|
|
@ -252,6 +252,7 @@ fn test_matcher() {
|
|||
level: LogLevel::Error,
|
||||
message: "Unsupported query value for mimetype: %/text, only values in the format \"mime/type\" or \"mime/%\" are supported".into(),
|
||||
exception: Some(Exception {
|
||||
message: "".into(),
|
||||
exception: "Bar\\FooException".into(),
|
||||
file: "short".into(),
|
||||
line: 68,
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ fn log_row(line: &LogLine) -> Row<'static> {
|
|||
Row::new([
|
||||
Text::from(line.level.as_str().to_string()),
|
||||
Text::from(line.app.to_string()),
|
||||
Text::from(line.message.clone()),
|
||||
Text::from(line.display()),
|
||||
Text::from(line.time.format(&Iso8601::<TIME_FORMAT>).unwrap()).alignment(Alignment::Right),
|
||||
])
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ fn group_row(app: &App, group: &GroupedLines) -> Row<'static> {
|
|||
Row::new([
|
||||
line.level.as_str().to_string(),
|
||||
line.app.to_string(),
|
||||
line.message.clone(),
|
||||
line.display(),
|
||||
sparkline(&group.histogram.counts(10)),
|
||||
group.len().to_string(),
|
||||
])
|
||||
|
|
|
|||
|
|
@ -179,7 +179,11 @@ mod table_state {
|
|||
fn up(&mut self, count: usize, step: usize) -> usize {
|
||||
let current = self.selected().unwrap_or(0);
|
||||
let after = if step > current {
|
||||
count - 1
|
||||
if step == 1 {
|
||||
count - 1
|
||||
} else {
|
||||
0
|
||||
}
|
||||
} else {
|
||||
current - step
|
||||
};
|
||||
|
|
@ -190,7 +194,11 @@ mod table_state {
|
|||
fn down(&mut self, count: usize, step: usize) -> usize {
|
||||
let current = self.selected().unwrap_or(0);
|
||||
let after = if step >= count - current {
|
||||
0
|
||||
if step == 1 {
|
||||
0
|
||||
} else {
|
||||
count - 1
|
||||
}
|
||||
} else {
|
||||
current + step
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue