mirror of
https://codeberg.org/icewind/logsmash.git
synced 2026-06-03 10:04:12 +02:00
linenumber
This commit is contained in:
parent
efcb86d2cf
commit
f7ed810253
6 changed files with 23 additions and 17 deletions
7
Cargo.lock
generated
7
Cargo.lock
generated
|
|
@ -485,6 +485,7 @@ dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn",
|
"syn",
|
||||||
|
"unicode-xid",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
@ -1520,6 +1521,12 @@ version = "0.2.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1fc81956842c57dac11422a97c3b8195a1ff727f06e85c84ed2e8aa277c9a0fd"
|
checksum = "1fc81956842c57dac11422a97c3b8195a1ff727f06e85c84ed2e8aa277c9a0fd"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "unicode-xid"
|
||||||
|
version = "0.2.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "utf8parse"
|
name = "utf8parse"
|
||||||
version = "0.2.2"
|
version = "0.2.2"
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ time = { version = "0.3.37", features = ["serde", "serde-well-known", "parsing",
|
||||||
hdrhistogram = "7.5.4"
|
hdrhistogram = "7.5.4"
|
||||||
ahash = "0.8.11"
|
ahash = "0.8.11"
|
||||||
base64 = "0.22.1"
|
base64 = "0.22.1"
|
||||||
derive_more = { version = "2.0.1", features = ["from"] }
|
derive_more = { version = "2.0.1", features = ["from", "display"] }
|
||||||
rayon = "1.10.0"
|
rayon = "1.10.0"
|
||||||
tar = "0.4.43"
|
tar = "0.4.43"
|
||||||
zip = "2.2.2"
|
zip = "2.2.2"
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
use crate::app::Filter;
|
use crate::app::Filter;
|
||||||
use crate::logfile::LogIndex;
|
use crate::logfile::LogIndex;
|
||||||
use ahash::AHasher;
|
use ahash::AHasher;
|
||||||
|
use derive_more::{Display, From};
|
||||||
use logsmash_data::LogLevel;
|
use logsmash_data::LogLevel;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
|
|
@ -164,13 +165,18 @@ impl<'a> LogLine<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(
|
||||||
|
Default, Deserialize, Debug, Copy, Clone, Hash, Display, From, PartialEq, Eq, Ord, PartialOrd,
|
||||||
|
)]
|
||||||
|
pub struct LineNumber(usize);
|
||||||
|
|
||||||
#[derive(Deserialize, Debug, Hash, Clone)]
|
#[derive(Deserialize, Debug, Hash, Clone)]
|
||||||
#[serde(rename_all = "PascalCase")]
|
#[serde(rename_all = "PascalCase")]
|
||||||
pub struct Exception<'a> {
|
pub struct Exception<'a> {
|
||||||
pub message: Cow<'a, str>,
|
pub message: Cow<'a, str>,
|
||||||
pub exception: Cow<'a, str>,
|
pub exception: Cow<'a, str>,
|
||||||
pub file: Cow<'a, str>,
|
pub file: Cow<'a, str>,
|
||||||
pub line: usize,
|
pub line: LineNumber,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize, Clone)]
|
#[derive(Deserialize, Clone)]
|
||||||
|
|
@ -203,7 +209,7 @@ pub struct FullException {
|
||||||
pub code: ExceptionCode,
|
pub code: ExceptionCode,
|
||||||
pub trace: Vec<Trace>,
|
pub trace: Vec<Trace>,
|
||||||
pub file: String,
|
pub file: String,
|
||||||
pub line: usize,
|
pub line: LineNumber,
|
||||||
pub previous: Option<Box<FullException>>,
|
pub previous: Option<Box<FullException>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -228,13 +234,10 @@ impl FullException {
|
||||||
pub struct Trace {
|
pub struct Trace {
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub file: String,
|
pub file: String,
|
||||||
#[serde(default)]
|
pub line: LineNumber,
|
||||||
pub line: usize,
|
|
||||||
#[serde(default)]
|
|
||||||
pub function: String,
|
pub function: String,
|
||||||
#[serde(default)]
|
|
||||||
pub class: String,
|
pub class: String,
|
||||||
#[serde(default, rename = "type")]
|
#[serde(rename = "type")]
|
||||||
pub ty: Option<TinyAsciiStr<4>>,
|
pub ty: Option<TinyAsciiStr<4>>,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub args: Vec<Value>,
|
pub args: Vec<Value>,
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ use crate::logfile::archive::{Archive, ArchiveEntry, TarArchive, ZipArchive};
|
||||||
use bzip2_rs::DecoderReader;
|
use bzip2_rs::DecoderReader;
|
||||||
use dialoguer::Select;
|
use dialoguer::Select;
|
||||||
use flate2::read::GzDecoder;
|
use flate2::read::GzDecoder;
|
||||||
pub use logline::LogLine;
|
pub use logline::{LineNumber, LogLine};
|
||||||
use ruzstd::decoding::StreamingDecoder;
|
use ruzstd::decoding::StreamingDecoder;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use std::io::{Cursor, Read, Seek};
|
use std::io::{Cursor, Read, Seek};
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
use crate::logfile::logline::{Exception, LogLine};
|
use crate::logfile::logline::{Exception, LogLine};
|
||||||
|
use crate::logfile::LineNumber;
|
||||||
use itertools::Either;
|
use itertools::Either;
|
||||||
use logsmash_data::{LogLevel, LoggingStatement, StatementList};
|
use logsmash_data::{LogLevel, LoggingStatement, StatementList};
|
||||||
use std::hash::{Hash, Hasher};
|
use std::hash::{Hash, Hasher};
|
||||||
|
|
@ -11,7 +12,7 @@ pub struct LogMatch {
|
||||||
pattern: &'static str,
|
pattern: &'static str,
|
||||||
exception: Option<&'static str>,
|
exception: Option<&'static str>,
|
||||||
path: &'static str,
|
path: &'static str,
|
||||||
line: usize,
|
line: LineNumber,
|
||||||
index: usize,
|
index: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -26,7 +27,7 @@ impl LogMatch {
|
||||||
},
|
},
|
||||||
exception: statement.exception,
|
exception: statement.exception,
|
||||||
path: statement.path,
|
path: statement.path,
|
||||||
line: statement.line,
|
line: statement.line.into(),
|
||||||
index,
|
index,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -142,12 +142,7 @@ fn trace_line(trace: &Trace, path_prefix_length: usize) -> Row {
|
||||||
.get(path_prefix_length..)
|
.get(path_prefix_length..)
|
||||||
.unwrap_or_default(),
|
.unwrap_or_default(),
|
||||||
),
|
),
|
||||||
Text::from(if trace.line > 0 {
|
Text::from(trace.line.to_string()).alignment(Alignment::Right),
|
||||||
trace.line.to_string()
|
|
||||||
} else {
|
|
||||||
String::new()
|
|
||||||
})
|
|
||||||
.alignment(Alignment::Right),
|
|
||||||
Text::from(trace.function().to_string()),
|
Text::from(trace.function().to_string()),
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue