diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2016-10-15 11:24:14 +0200 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2016-10-15 11:24:14 +0200 |
commit | 9c29bf19dadb35914942925c8c1716266f313ecf (patch) | |
tree | 0906be70bc9ffde44faa2c1327948228e7fdf126 /libimagentrylink | |
parent | 4e2bcf7d584314fcfcf14eb8d730c781e1a027cf (diff) |
Add debugging output
Diffstat (limited to 'libimagentrylink')
-rw-r--r-- | libimagentrylink/src/internal.rs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/libimagentrylink/src/internal.rs b/libimagentrylink/src/internal.rs index 79e37329..267739ef 100644 --- a/libimagentrylink/src/internal.rs +++ b/libimagentrylink/src/internal.rs @@ -144,6 +144,8 @@ impl InternalLinker for Entry { fn add_internal_link(&mut self, link: &mut Entry) -> Result<()> { let new_link = link.get_location().clone(); + debug!("Adding internal link from {:?} to {:?}", self.get_location(), new_link); + add_foreign_link(link, self.get_location().clone()) .and_then(|_| { self.get_internal_links() @@ -158,13 +160,17 @@ impl InternalLinker for Entry { let own_loc = link.get_location().clone(); let other_loc = link.get_location().clone(); + debug!("Removing internal link from {:?} to {:?}", own_loc, other_loc); + link.get_internal_links() .and_then(|links| { + debug!("Rewriting own links for {:?}, without {:?}", other_loc, own_loc); rewrite_links(self.get_header_mut(), links.filter(|l| *l != own_loc)) }) .and_then(|_| { self.get_internal_links() .and_then(|links| { + debug!("Rewriting own links for {:?}, without {:?}", own_loc, other_loc); rewrite_links(link.get_header_mut(), links.filter(|l| *l != other_loc)) }) }) @@ -184,6 +190,7 @@ fn rewrite_links<I: Iterator<Item = Link>>(header: &mut EntryHeader, links: I) - }) })); + debug!("Setting new link array: {:?}", links); let process = header.set("imag.links", Value::Array(links)); process_rw_result(process).map(|_| ()) } @@ -191,6 +198,7 @@ fn rewrite_links<I: Iterator<Item = Link>>(header: &mut EntryHeader, links: I) - /// When Linking A -> B, the specification wants us to link back B -> A. /// This is a helper function which does this. fn add_foreign_link(target: &mut Entry, from: StoreId) -> Result<()> { + debug!("Linking back from {:?} to {:?}", target.get_location(), from); target.get_internal_links() .and_then(|links| { let links = try!(links @@ -205,6 +213,7 @@ fn add_foreign_link(target: &mut Entry, from: StoreId) -> Result<()> { }) }) })); + debug!("Setting links in {:?}: {:?}", target.get_location(), links); process_rw_result(target.get_header_mut().set("imag.links", Value::Array(links))) .map(|_| ()) }) @@ -293,6 +302,9 @@ mod test { let e1_links = e1.get_internal_links().unwrap().collect::<Vec<_>>(); let e2_links = e2.get_internal_links().unwrap().collect::<Vec<_>>(); + debug!("1 has links: {:?}", e1_links); + debug!("2 has links: {:?}", e2_links); + assert_eq!(e1_links.len(), 1); assert_eq!(e2_links.len(), 1); |