aboutsummaryrefslogtreecommitdiff
path: root/src/format/weechat3.rs
diff options
context:
space:
mode:
authorTill Hoeppner2015-07-29 00:01:46 +0200
committerTill Hoeppner2015-07-29 00:01:46 +0200
commit09f6509050f24e54c9859e0905e8b6731d91f39f (patch)
tree1916aaf8e8bb6d978000f4233bbe690228256ef7 /src/format/weechat3.rs
parent434048f7252c2490f04866c9a08eff6eb1688dc3 (diff)
downloadilc-09f6509050f24e54c9859e0905e8b6731d91f39f.tar.gz
ilc-09f6509050f24e54c9859e0905e8b6731d91f39f.tar.xz
ilc-09f6509050f24e54c9859e0905e8b6731d91f39f.zip
implement sort and dedup of logs
Diffstat (limited to 'src/format/weechat3.rs')
-rw-r--r--src/format/weechat3.rs12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/format/weechat3.rs b/src/format/weechat3.rs
index 3ff781c..e733a38 100644
--- a/src/format/weechat3.rs
+++ b/src/format/weechat3.rs
@@ -29,7 +29,7 @@ static TIME_DATE_FORMAT: &'static str = "%Y-%m-%d %H:%M:%S";
pub struct Iter<'a, R: 'a> where R: BufRead {
context: &'a Context,
input: R,
- buffer: String
+ buffer: Vec<u8>
}
impl<'a, R: 'a> Iterator for Iter<'a, R> where R: BufRead {
@@ -41,18 +41,20 @@ impl<'a, R: 'a> Iterator for Iter<'a, R> where R: BufRead {
loop {
self.buffer.clear();
- match self.input.read_line(&mut self.buffer) {
+ match self.input.read_until(b'\n', &mut self.buffer) {
Ok(0) | Err(_) => return None,
Ok(_) => ()
}
+ let buffer = String::from_utf8_lossy(&self.buffer);
+
let mut split_tokens: Vec<char> = Vec::new();
- let tokens = self.buffer.split(|c: char| {
+ let tokens = buffer.split(|c: char| {
if c.is_whitespace() { split_tokens.push(c); true } else { false }
}).collect::<Vec<_>>();
if log_enabled!(Info) {
- info!("Original: `{}`", self.buffer);
+ info!("Original: `{}`", buffer);
info!("Parsing: {:?}", tokens);
}
@@ -143,7 +145,7 @@ impl<'a, I: 'a> Decode<'a, I> for Weechat3 where I: BufRead {
Iter {
context: context,
input: input,
- buffer: String::new()
+ buffer: Vec::new()
}
}
}