From 9edad2800fd5ba58a1c1a92de49d5028dbff910d Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 27 Nov 2015 22:18:26 +0100 Subject: [PATCH] Add debugging output in storage parser code --- src/storage/parser.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/storage/parser.rs b/src/storage/parser.rs index f36eb4f1..dc0d28c9 100644 --- a/src/storage/parser.rs +++ b/src/storage/parser.rs @@ -99,28 +99,36 @@ impl<'a, HP> Parser where pub fn read(&self, s: String) -> Result<(FileHeaderData, String), ParserError> { + debug!("Reading into internal datastructure: '{}'", s); let divided = self.divide_text(&s); if divided.is_err() { + debug!("Error reading into internal datastructure"); return Err(divided.err().unwrap()); } let (header, data) = divided.ok().unwrap(); + debug!("Header = '{:?}'", header); + debug!("Data = '{:?}'", data); let h_parseres = try!(self.headerp.read(header)); + debug!("Success parsing header"); Ok((h_parseres, data.unwrap_or(String::new()))) } pub fn write(&self, tpl : (FileHeaderData, String)) -> Result { + debug!("Parsing internal datastructure to String"); let (header, data) = tpl; let h_text = try!(self.headerp.write(&header)); + debug!("Success translating header"); Ok(h_text + &data[..]) } fn divide_text(&self, text: &String) -> Result { + debug!("Splitting: '{}'", text); let re = Regex::new(r"(?m)^\-\-\-$\n(.*)^\-\-\-$\n(.*)").unwrap(); let captures = re.captures(&text[..]).unwrap_or( @@ -137,6 +145,9 @@ impl<'a, HP> Parser where let header = captures.at(0).map(|s| String::from(s)); let content = captures.at(1).map(|s| String::from(s)); + + debug!("Splitted, Header = '{:?}'", header); + debug!("Splitted, Data = '{:?}'", content); Ok((header, content)) }