|
|
@ -45,10 +45,10 @@ fn chunk64(delta_chunk: &Vec<u8>, size_chunk: &Vec<u8>) -> Result<(i32, i32)> {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// parse the log of raw bytes and make some nice json for clients
|
|
|
|
/// parse the log of raw bytes and make some nice json for clients
|
|
|
|
pub fn parse_log(raw: &Vec<u8>) -> Result<Value> {
|
|
|
|
pub fn parse_log(raw: &Vec<u8>) -> Result<(i32, Value)> {
|
|
|
|
let mut raw = raw.to_owned();
|
|
|
|
let mut raw = raw.to_owned();
|
|
|
|
let mut chunks: Vec<Map<String, Value>> = Vec::new();
|
|
|
|
let mut chunks: Vec<Map<String, Value>> = Vec::new();
|
|
|
|
let mut lineno = 1;
|
|
|
|
let mut lineno = 0;
|
|
|
|
|
|
|
|
|
|
|
|
while raw.len() > 0 {
|
|
|
|
while raw.len() > 0 {
|
|
|
|
let chunk: Vec<u8> = raw.drain(0..8).collect();
|
|
|
|
let chunk: Vec<u8> = raw.drain(0..8).collect();
|
|
|
@ -84,15 +84,15 @@ pub fn parse_log(raw: &Vec<u8>) -> Result<Value> {
|
|
|
|
text = convert_escaped(&text)?;
|
|
|
|
text = convert_escaped(&text)?;
|
|
|
|
|
|
|
|
|
|
|
|
for line in text.lines() {
|
|
|
|
for line in text.lines() {
|
|
|
|
|
|
|
|
lineno += 1;
|
|
|
|
let mut map: Map<String, Value> = Map::new();
|
|
|
|
let mut map: Map<String, Value> = Map::new();
|
|
|
|
map.insert("lineno".into(), lineno.into());
|
|
|
|
map.insert("lineno".into(), lineno.into());
|
|
|
|
map.insert("delta".into(), delta.into());
|
|
|
|
map.insert("delta".into(), delta.into());
|
|
|
|
map.insert("text".into(), line.trim().into());
|
|
|
|
map.insert("text".into(), line.trim().into());
|
|
|
|
chunks.push(map);
|
|
|
|
chunks.push(map);
|
|
|
|
delta = 0;
|
|
|
|
delta = 0;
|
|
|
|
lineno += 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Ok(chunks.into())
|
|
|
|
Ok((lineno, chunks.into()))
|
|
|
|
}
|
|
|
|
}
|
|
|
|