1use std::collections::HashMap;
2use std::path::Path;
3use std::fs::File;
4use std::error::Error;
5use std::io::BufReader;
6use std::io::prelude::*;
7
8pub mod actor;
9mod log_entry;
10mod http;
11mod hash_utils;
12
13mod nginx;
14
15pub fn process(logfile: &str) -> Result<HashMap<String, actor::Actor>, String> {
16 let path = Path::new(logfile);
17 let file_handle = match File::open(&path) {
18 Err(why) => {
19 return Err(format!("Could not open {} : {}", path.display(), Error::description(&why)));
20 },
21 Ok(file) => file,
22 };
23
24 let reader = BufReader::new(file_handle);
25 let mut actors = HashMap::<String, actor::Actor>::new();
26 for line in reader.lines() {
27 match line {
28 Ok(line) => nginx::process(&mut actors, &line),
29 Err(e) => return Err(format!("ERROR {}", e)),
30 }
31 }
32
33 return Ok(actors);
34}