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:
|
Currently, the program can match against data from the following sources:
|
||||||
|
|
||||||
- Nextcloud server 29
|
- Nextcloud server 24 - 29
|
||||||
- files_accesscontrol 1.19.1
|
- files_accesscontrol 1.19.1
|
||||||
- files_antivirus 5.5.7
|
- files_antivirus 5.5.7
|
||||||
- deck: 1.13.1
|
- deck: 1.13.1
|
||||||
|
- calendar: 4.7.13
|
||||||
|
|
||||||
### Updating baked data
|
### Updating baked data
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,10 +4,11 @@ final: prev: let
|
||||||
inherit (prev.lib) importJSON;
|
inherit (prev.lib) importJSON;
|
||||||
inherit (prev.lib.lists) flatten;
|
inherit (prev.lib.lists) flatten;
|
||||||
allPackages = importJSON ./versions.json;
|
allPackages = importJSON ./versions.json;
|
||||||
packages = {
|
# packages = {
|
||||||
server = {"29" = allPackages.server."29";};
|
# server = {"29" = allPackages.server."29";};
|
||||||
inherit (allPackages) files_accesscontrol files_antivirus deck;
|
# inherit (allPackages) files_accesscontrol files_antivirus deck;
|
||||||
};
|
# };
|
||||||
|
packages = allPackages;
|
||||||
|
|
||||||
loggingFor = mode: name:
|
loggingFor = mode: name:
|
||||||
mapAttrs (major: data: (final.callPackage ./extracted-logs.nix {
|
mapAttrs (major: data: (final.callPackage ./extracted-logs.nix {
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
makeRustPlatform,
|
makeRustPlatform,
|
||||||
rust-bin,
|
rust-bin,
|
||||||
lib,
|
lib,
|
||||||
|
extracted-logs-rust,
|
||||||
}: let
|
}: let
|
||||||
inherit (lib.sources) sourceByRegex;
|
inherit (lib.sources) sourceByRegex;
|
||||||
src = sourceByRegex ../. ["Cargo.*" "(src|data)(/.*)?"];
|
src = sourceByRegex ../. ["Cargo.*" "(src|data)(/.*)?"];
|
||||||
|
|
@ -17,6 +18,11 @@ in
|
||||||
|
|
||||||
inherit src;
|
inherit src;
|
||||||
|
|
||||||
|
preBuild = ''
|
||||||
|
rm -r data/src/data
|
||||||
|
cp -r ${extracted-logs-rust} data/src/data
|
||||||
|
'';
|
||||||
|
|
||||||
cargoLock = {
|
cargoLock = {
|
||||||
lockFile = ../Cargo.lock;
|
lockFile = ../Cargo.lock;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -25,14 +25,47 @@ impl LogLine {
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map(|e| e.exception.as_str())
|
.map(|e| e.exception.as_str())
|
||||||
.hash(&mut hasher);
|
.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);
|
self.app.hash(&mut hasher);
|
||||||
hasher.finish()
|
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)]
|
#[derive(Deserialize, Debug)]
|
||||||
#[serde(rename_all = "PascalCase")]
|
#[serde(rename_all = "PascalCase")]
|
||||||
pub struct Exception {
|
pub struct Exception {
|
||||||
|
pub message: String,
|
||||||
pub exception: String,
|
pub exception: String,
|
||||||
pub file: String,
|
pub file: String,
|
||||||
pub line: usize,
|
pub line: usize,
|
||||||
|
|
|
||||||
|
|
@ -22,8 +22,6 @@ mod ui;
|
||||||
#[derive(Debug, Parser)]
|
#[derive(Debug, Parser)]
|
||||||
struct Args {
|
struct Args {
|
||||||
file: String,
|
file: String,
|
||||||
#[arg(long)]
|
|
||||||
unmatched: bool,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() -> MainResult {
|
fn main() -> MainResult {
|
||||||
|
|
@ -72,16 +70,11 @@ fn main() -> MainResult {
|
||||||
};
|
};
|
||||||
if let Some(index) = matcher.match_log(&parsed) {
|
if let Some(index) = matcher.match_log(&parsed) {
|
||||||
counts.entry(index).or_default().push(i);
|
counts.entry(index).or_default().push(i);
|
||||||
} else {
|
} else if let Some(entry) = unmatched_counts.get_mut(parsed.app.as_str()) {
|
||||||
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)
|
entry.push(i)
|
||||||
} else {
|
} else {
|
||||||
unmatched_lines.push(i);
|
unmatched_lines.push(i);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
parsed_lines.push(parsed);
|
parsed_lines.push(parsed);
|
||||||
i += 1;
|
i += 1;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -252,6 +252,7 @@ fn test_matcher() {
|
||||||
level: LogLevel::Error,
|
level: LogLevel::Error,
|
||||||
message: "Unsupported query value for mimetype: %/text, only values in the format \"mime/type\" or \"mime/%\" are supported".into(),
|
message: "Unsupported query value for mimetype: %/text, only values in the format \"mime/type\" or \"mime/%\" are supported".into(),
|
||||||
exception: Some(Exception {
|
exception: Some(Exception {
|
||||||
|
message: "".into(),
|
||||||
exception: "Bar\\FooException".into(),
|
exception: "Bar\\FooException".into(),
|
||||||
file: "short".into(),
|
file: "short".into(),
|
||||||
line: 68,
|
line: 68,
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ fn log_row(line: &LogLine) -> Row<'static> {
|
||||||
Row::new([
|
Row::new([
|
||||||
Text::from(line.level.as_str().to_string()),
|
Text::from(line.level.as_str().to_string()),
|
||||||
Text::from(line.app.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),
|
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([
|
Row::new([
|
||||||
line.level.as_str().to_string(),
|
line.level.as_str().to_string(),
|
||||||
line.app.to_string(),
|
line.app.to_string(),
|
||||||
line.message.clone(),
|
line.display(),
|
||||||
sparkline(&group.histogram.counts(10)),
|
sparkline(&group.histogram.counts(10)),
|
||||||
group.len().to_string(),
|
group.len().to_string(),
|
||||||
])
|
])
|
||||||
|
|
|
||||||
|
|
@ -179,7 +179,11 @@ mod table_state {
|
||||||
fn up(&mut self, count: usize, step: usize) -> usize {
|
fn up(&mut self, count: usize, step: usize) -> usize {
|
||||||
let current = self.selected().unwrap_or(0);
|
let current = self.selected().unwrap_or(0);
|
||||||
let after = if step > current {
|
let after = if step > current {
|
||||||
|
if step == 1 {
|
||||||
count - 1
|
count - 1
|
||||||
|
} else {
|
||||||
|
0
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
current - step
|
current - step
|
||||||
};
|
};
|
||||||
|
|
@ -190,7 +194,11 @@ mod table_state {
|
||||||
fn down(&mut self, count: usize, step: usize) -> usize {
|
fn down(&mut self, count: usize, step: usize) -> usize {
|
||||||
let current = self.selected().unwrap_or(0);
|
let current = self.selected().unwrap_or(0);
|
||||||
let after = if step >= count - current {
|
let after = if step >= count - current {
|
||||||
|
if step == 1 {
|
||||||
0
|
0
|
||||||
|
} else {
|
||||||
|
count - 1
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
current + step
|
current + step
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue