track line numbers

master
rascul 2 years ago
parent 0fcc39b14a
commit 2960710987

@ -48,6 +48,7 @@ fn chunk64(delta_chunk: &Vec<u8>, size_chunk: &Vec<u8>) -> Result<(i32, i32)> {
pub fn parse_log(raw: &Vec<u8>) -> Result<Value> {
let mut raw = raw.to_owned();
let mut chunks: Vec<Map<String, Value>> = Vec::new();
let mut lineno = 1;
while raw.len() > 0 {
let chunk: Vec<u8> = raw.drain(0..8).collect();
@ -84,10 +85,12 @@ pub fn parse_log(raw: &Vec<u8>) -> Result<Value> {
for line in text.lines() {
let mut map: Map<String, Value> = Map::new();
map.insert("lineno".into(), lineno.into());
map.insert("delta".into(), delta.into());
map.insert("text".into(), line.trim().into());
chunks.push(map);
delta = 0;
lineno += 1;
}
}

Loading…
Cancel
Save