Initial something
This commit is contained in:
commit
8cd88c761b
11 changed files with 338146 additions and 0 deletions
60
src/main.rs
Normal file
60
src/main.rs
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
#[macro_use]
|
||||
extern crate serde_derive;
|
||||
extern crate serde;
|
||||
extern crate rmp_serde;
|
||||
extern crate regex;
|
||||
extern crate serde_json;
|
||||
|
||||
use env;
|
||||
use regex::RegexSet;
|
||||
use std::io::BufRead;
|
||||
use std::process::{Command,Stdio};
|
||||
|
||||
#[derive(Serialize, Debug)]
|
||||
struct Entry {
|
||||
source: u32,
|
||||
level: u8,
|
||||
time: u64,
|
||||
event: String,
|
||||
details: String
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let args: Vec<String> = env::args().collect();
|
||||
|
||||
let prog = &args[1];
|
||||
let prog_args = ["biglog"];
|
||||
let prog_dir = "testdata";
|
||||
|
||||
let child = Command::new(prog)
|
||||
.args(&prog_args)
|
||||
.current_dir(prog_dir)
|
||||
.stdout(Stdio::piped())
|
||||
.spawn()
|
||||
.expect("Spawn failed");
|
||||
|
||||
let lineset = [r"^ "];
|
||||
|
||||
let regset = RegexSet::new(&lineset).unwrap();
|
||||
|
||||
let reader = std::io::BufReader::new(child.stdout.unwrap());
|
||||
for line in reader.lines() {
|
||||
let line = line.unwrap();
|
||||
let matches: Vec<_> = regset.matches(&line).into_iter().collect();
|
||||
match matches.len() {
|
||||
0 => {
|
||||
println!("UNKNOWN: {}", &line);
|
||||
},
|
||||
1 => {
|
||||
println!("EXACT: {}", &line);
|
||||
},
|
||||
_ => {
|
||||
print!("FAIL(");
|
||||
for ri in matches {
|
||||
print!("{},", ri);
|
||||
}
|
||||
println!("): {}", &line);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue