mirror of
https://codeberg.org/icewind/logsmash.git
synced 2026-06-03 10:04:12 +02:00
support reading log.gz files
This commit is contained in:
parent
6213aff07e
commit
4737a0db3c
4 changed files with 13 additions and 3 deletions
5
Cargo.lock
generated
5
Cargo.lock
generated
|
|
@ -404,9 +404,9 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "flate2"
|
name = "flate2"
|
||||||
version = "1.0.30"
|
version = "1.0.31"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "5f54427cfd1c7829e2a139fcefea601bf088ebca651d2bf53ebc600eac295dae"
|
checksum = "7f211bbe8e69bbd0cfdea405084f128ae8b4aaa6b0b522fc8f2b009084797920"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"crc32fast",
|
"crc32fast",
|
||||||
"miniz_oxide",
|
"miniz_oxide",
|
||||||
|
|
@ -574,6 +574,7 @@ dependencies = [
|
||||||
"base64",
|
"base64",
|
||||||
"clap",
|
"clap",
|
||||||
"derive_more",
|
"derive_more",
|
||||||
|
"flate2",
|
||||||
"hdrhistogram",
|
"hdrhistogram",
|
||||||
"itertools",
|
"itertools",
|
||||||
"log",
|
"log",
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ log = "0.4.22"
|
||||||
clap = { version = "=4.1.3", features = ["derive"] }
|
clap = { version = "=4.1.3", features = ["derive"] }
|
||||||
logsmash-data = { version = "0.1.0", path = "./data" }
|
logsmash-data = { version = "0.1.0", path = "./data" }
|
||||||
zip = "2.1.5"
|
zip = "2.1.5"
|
||||||
|
flate2 = "1.0.31"
|
||||||
itertools = "0.13.0"
|
itertools = "0.13.0"
|
||||||
ratatui = "0.27.0"
|
ratatui = "0.27.0"
|
||||||
tinystr = { version = "0.7.6", features = ["serde"] }
|
tinystr = { version = "0.7.6", features = ["serde"] }
|
||||||
|
|
|
||||||
|
|
@ -100,7 +100,8 @@ Currently, the program can match against data from the following sources:
|
||||||
## Roadmap
|
## Roadmap
|
||||||
|
|
||||||
- [ ] More flexible log file input
|
- [ ] More flexible log file input
|
||||||
- [ ] Log files compressed trough gzip, xz, etc
|
- [x] Log files compressed trough gzip
|
||||||
|
- [ ] Log files compressed trough other compression methods
|
||||||
- [ ] Archived containing more than one file
|
- [ ] Archived containing more than one file
|
||||||
- [ ] Data from more app version
|
- [ ] Data from more app version
|
||||||
- [ ] Support extracting app versions from a system report
|
- [ ] Support extracting app versions from a system report
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
use crate::error::ReadError;
|
use crate::error::ReadError;
|
||||||
|
use flate2::read::GzDecoder;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::Read;
|
use std::io::Read;
|
||||||
use zip::ZipArchive;
|
use zip::ZipArchive;
|
||||||
|
|
@ -22,6 +23,12 @@ impl LogFile {
|
||||||
let mut content = String::with_capacity(log.size() as usize);
|
let mut content = String::with_capacity(log.size() as usize);
|
||||||
log.read_to_string(&mut content)?;
|
log.read_to_string(&mut content)?;
|
||||||
|
|
||||||
|
Ok(LogFile { content })
|
||||||
|
} else if path.ends_with(".gz") {
|
||||||
|
let mut decoder = GzDecoder::new(file);
|
||||||
|
let mut content = String::new();
|
||||||
|
decoder.read_to_string(&mut content)?;
|
||||||
|
|
||||||
Ok(LogFile { content })
|
Ok(LogFile { content })
|
||||||
} else {
|
} else {
|
||||||
let mut content = String::new();
|
let mut content = String::new();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue