diff --git a/Cargo.toml b/Cargo.toml index 63c2c0e..1a00fdc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,7 +16,3 @@ features = ["with-chrono-0_4"] [dependencies.futures-preview] version = "=0.3.0-alpha.19" features = [ "async-await" ] - -[profile.release] -lto = "fat" -codegen-units = 1 diff --git a/src/main.rs b/src/main.rs index b99b83b..bdbdf18 100644 --- a/src/main.rs +++ b/src/main.rs @@ -50,7 +50,6 @@ async fn main() -> Result<(), Error> { tokio::spawn(connection); client.execute("create table if not exists log( - prio smallint, rcv_ip inet, rcv_date timestamptz, date timestamptz, @@ -62,7 +61,7 @@ async fn main() -> Result<(), Error> { let client = Arc::new(client); let insert_statement = client - .prepare("insert into log(prio, rcv_ip, rcv_date, date, daemon, message) values ($1, $2, $3, $4, $5, $6)").await?; + .prepare("insert into log(rcv_ip, rcv_date, date, daemon, message) values ($1, $2, $3, $4, $5)").await?; let mut listener = TcpListener::bind(&options.addr).await .map_err(|e| format!("could not bind to {} with error {:?}", &options.addr, e))?; @@ -101,9 +100,9 @@ async fn handle_peer(stream: TcpStream, peer: SocketAddr, db: Arc, inser loop { match lines.next().await.transpose()? { Some(line) => { - let (prio, now, date, service, log) = parse_line(&line)?; + let (now, date, service, log) = parse_line(&line)?; if !blacklist.contains(service) { - db.execute(&insert_statement, &[&prio, &ip, &now, &date, &service, &log]).await?; + db.execute(&insert_statement, &[&ip, &now, &date, &service, &log]).await?; } }, None => break, @@ -119,15 +118,7 @@ async fn handle_peer(stream: TcpStream, peer: SocketAddr, db: Arc, inser * , log entry * ) */ -fn parse_line(line: &'_ str) -> Result<(i16, DateTime, DateTime, &'_ str, &'_ str), Error> { - let mut prio_and_remainder = line.splitn(2, '>'); - let prio = prio_and_remainder.next().ok_or("log did not contain priority")?; - let prio = &prio[1..]; - let prio = prio.parse() - .map_err(|e| format!("could not parse priority {}: {}",prio, e))?; - - - let line = prio_and_remainder.next().expect("splitn should always return a second part"); +fn parse_line(line: &'_ str) -> Result<(DateTime, DateTime, &'_ str, &'_ str), Error> { let (date, line) = line.split_at(16); // we need to prepend the current year and timezone, as that is not stated in the logfile @@ -135,8 +126,7 @@ fn parse_line(line: &'_ str) -> Result<(i16, DateTime, DateTime Result<(i16, DateTime, DateTime