aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTill Hoeppner2015-04-02 00:19:23 +0200
committerTill Hoeppner2015-04-02 00:19:23 +0200
commit522ba8bdc2d63c6503324baf3eacdaa0630f4673 (patch)
tree0935eb5797660cf03445dfca2b3a78f98405a8f4
parenta02f3c09482807220c5642b0e03d8f2d8aea243a (diff)
downloadilc-522ba8bdc2d63c6503324baf3eacdaa0630f4673.tar.gz
ilc-522ba8bdc2d63c6503324baf3eacdaa0630f4673.tar.xz
ilc-522ba8bdc2d63c6503324baf3eacdaa0630f4673.zip
Proper logging, proper parsing
-rw-r--r--Cargo.toml8
-rw-r--r--src/format/weechat3.rs7
-rw-r--r--src/main.rs2
3 files changed, 14 insertions, 3 deletions
diff --git a/Cargo.toml b/Cargo.toml
index 1ca4ef8..12d8b2e 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -10,3 +10,11 @@ regex_macros = "*"
chrono = "*"
docopt = "*"
rustc-serialize = "*"
+log = "*"
+env_logger = "*"
+
+[profile.release]
+opt-level = 3
+debug = false
+lto = true
+debug-assertions = false
diff --git a/src/format/weechat3.rs b/src/format/weechat3.rs
index 0837896..40445a1 100644
--- a/src/format/weechat3.rs
+++ b/src/format/weechat3.rs
@@ -34,7 +34,7 @@ impl<R> Iterator for Iter<R> where R: BufRead {
fn join(s: &[&str]) -> String {
let len = s.iter().map(|s| s.len()).sum();
let mut out = s.iter().fold(String::with_capacity(len),
- |mut s, b| { s.push_str(b); s.push(' '); s });
+ |mut s, b| { s.push_str(b); s.push(' '); s });
out.pop(); out
}
fn mask(s: &str) -> String {
@@ -50,9 +50,10 @@ impl<R> Iterator for Iter<R> where R: BufRead {
let tokens = self.buffer.split(|c: char| c.is_whitespace()).collect::<Vec<_>>();
if log_enabled!(Info) {
- info!("Parsing {:?}", tokens);
+ info!("Original: `{}`", self.buffer);
+ info!("Parsing: {:?}", tokens);
}
- match tokens.as_ref() {
+ match tokens[..tokens.len() - 1].as_ref() {
[date, time, "-->", nick, host, "has", "joined", channel, _..] => return Some(Ok(Event::Join {
nick: nick.to_owned(), channel: channel.to_owned(), mask: mask(host),
time: timestamp(date, time)
diff --git a/src/main.rs b/src/main.rs
index 4bf22f7..be86652 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -6,6 +6,7 @@ extern crate docopt;
extern crate rustc_serialize;
extern crate libc;
extern crate regex;
+extern crate env_logger;
use std::fs::File;
use std::io::{ self, BufReader };
@@ -44,6 +45,7 @@ struct Args {
}
fn main() {
+ env_logger::init().unwrap();
let args: Args = Docopt::new(USAGE)
.and_then(|d| d.decode())
.unwrap_or_else(|e| e.exit());