From 522ba8bdc2d63c6503324baf3eacdaa0630f4673 Mon Sep 17 00:00:00 2001 From: Till Hoeppner Date: Thu, 2 Apr 2015 00:19:23 +0200 Subject: Proper logging, proper parsing --- src/format/weechat3.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/format') 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 Iterator for Iter 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 Iterator for Iter where R: BufRead { let tokens = self.buffer.split(|c: char| c.is_whitespace()).collect::>(); 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) -- cgit v1.2.3