From ef18cb11445bda3c57dfeccfd05a5a0761a876ac Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 29 Jan 2016 20:14:27 +0100 Subject: [PATCH] Add extensive debugging output in utilities --- imag-store/src/util.rs | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/imag-store/src/util.rs b/imag-store/src/util.rs index 58c12533..0c033535 100644 --- a/imag-store/src/util.rs +++ b/imag-store/src/util.rs @@ -26,7 +26,15 @@ pub fn build_toml_header(matches: &ArgMatches, mut header: EntryHeader) -> Entry debug!("Building header from cli spec"); if let Some(headerspecs) = matches.values_of("header") { let mut main = header.toml_mut(); - for tpl in headerspecs.into_iter().filter_map(|hs| String::from(hs).into_kv()) { + debug!("headerspec = {:?}", headerspecs); + let kvs = headerspecs.into_iter() + .filter_map(|hs| { + debug!("- Processing: '{}'", hs); + let kv = String::from(hs).into_kv(); + debug!("- got: '{:?}'", kv); + kv + }); + for tpl in kvs { let (key, value) = tpl.into(); debug!("Splitting: {:?}", key); let mut split = key.split("."); @@ -36,6 +44,7 @@ pub fn build_toml_header(matches: &ArgMatches, mut header: EntryHeader) -> Entry } } } + debug!("Header = {:?}", header); header } @@ -46,8 +55,10 @@ fn insert_key_into(current: String, let next = rest_path.next(); if next.is_none() { + debug!("Inserting into {:?} = {:?}", current, value); map.insert(current, parse_value(value)); } else { + debug!("Inserting into {:?} ... = {:?}", current, value); if map.contains_key(¤t) { match map.get_mut(¤t).unwrap() { &mut Value::Table(ref mut t) => { @@ -58,6 +69,7 @@ fn insert_key_into(current: String, } else { let mut submap = BTreeMap::new(); insert_key_into(String::from(next.unwrap()), rest_path, value, &mut submap); + debug!("Inserting submap = {:?}", submap); map.insert(current, Value::Table(submap)); } } @@ -68,15 +80,18 @@ fn parse_value(value: String) -> Value { v.chars().next() == Some('[') && v.chars().last() == Some(']') && v.len() >= 3 } - debug!("Building value out of: {:?}", value); if value == "true" { + debug!("Building Boolean out of: {:?}...", value); Value::Boolean(true) } else if value == "false" { + debug!("Building Boolean out of: {:?}...", value); Value::Boolean(false) } else if is_ary(&value) { + debug!("Building Array out of: {:?}...", value); let sub = &value[1..(value.len()-1)]; Value::Array(sub.split(",").map(|v| parse_value(String::from(v))).collect()) } else { + debug!("Building String out of: {:?}...", value); Value::String(value) } }