summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2020-01-06 12:51:14 +0100
committerMatthias Beyer <mail@beyermatthias.de>2020-01-06 18:26:27 +0100
commit392d25a8107ed8a89797703d15e8b2a302d2b557 (patch)
tree37440a1b512cc548363ab368dbe006d7a2fba0b0
parent8048edae8d7dd37c5dd1fa86ab6c0df455c42a83 (diff)
Add debug and trace output
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
-rw-r--r--bin/domain/imag-mail/src/lib.rs23
1 files changed, 23 insertions, 0 deletions
diff --git a/bin/domain/imag-mail/src/lib.rs b/bin/domain/imag-mail/src/lib.rs
index 4d013ba3..fb2aa9fc 100644
--- a/bin/domain/imag-mail/src/lib.rs
+++ b/bin/domain/imag-mail/src/lib.rs
@@ -134,13 +134,23 @@ fn import(rt: &Runtime) -> Result<()> {
}
fn list(rt: &Runtime) -> Result<()> {
+ debug!("Listing mail");
let scmd = rt.cli().subcommand_matches("list").unwrap();
let store = rt.store();
let list_format = util::get_mail_print_format("mail.list_format", rt, &scmd)?;
+ debug!("List-format: {:?}", list_format);
+
let notmuch_path = crate::util::get_notmuch_database_path(rt)?;
+ debug!("notmuch path: {:?}", notmuch_path);
+
let notmuch_connection = NotmuchConnection::open(notmuch_path)?;
+
let tree = scmd.is_present("tree");
+ debug!("tree: {}", tree);
+
let find_root = scmd.is_present("find-root");
+ debug!("find_root: {}", find_root);
+
let mut out = rt.stdout();
let mut i = 0;
@@ -156,13 +166,18 @@ fn list(rt: &Runtime) -> Result<()> {
-> Result<()>
where I: Iterator<Item = Result<FileLockEntry<'a>>>
{
+ debug!("Processing non-tree");
iter.and_then_ok(|fle| {
+ trace!("Loading: {}", fle.get_location());
let loaded = fle.load(&conn)?
.ok_or_else(|| format_err!("Mail not found: {}", fle.get_location()))?;
+ trace!("Loaded: {}", fle.get_location());
let parsed = loaded.parsed()?;
+ trace!("Parsed: {}", fle.get_location());
let r = crate::util::list_mail(&parsed, *i, 0, list_format, out); // indentation hard coded to zero
+ trace!("Listed: {}", fle.get_location());
*i += 1; // poor mans enumerate()
r.map(|_| fle)
})
@@ -185,8 +200,10 @@ fn list(rt: &Runtime) -> Result<()> {
-> Result<()>
where I: Iterator<Item = Result<FileLockEntry<'a>>>
{
+ debug!("Processing tree");
let iter = if find_root {
let iter = iter.and_then_ok(|fle| {
+ trace!("Loading: {}", fle.get_location());
fle.load(conn)?
.ok_or_else(|| format_err!("Cannot load mail: {}", fle.get_location()))?
.parsed()?
@@ -272,14 +289,20 @@ fn print_traverse<'a>(store: &'a MailStoreWithConnection<'a>,
list_format: &Handlebars,
rt: &Runtime,
out: &mut dyn Write) -> Result<()> {
+ trace!("Print-Traversing starting with: {:?}", tree.root());
for (indent, mid) in tree.traverse() {
let fle = store.get_mail_by_id(&mid)?.ok_or_else(|| format_err!("Cannot find mail with id = {}", mid))?;
+ trace!("Printing: {}", fle.get_location());
+
let loaded = fle.load(&conn)?
.ok_or_else(|| format_err!("Mail not found: {}", fle.get_location()))?;
+ trace!("Loaded: {}", fle.get_location());
let parsed = loaded.parsed()?;
+ trace!("Parsed: {}", fle.get_location());
crate::util::list_mail(&parsed, *i, indent, list_format, out)?;
+ trace!("Listed: {}", fle.get_location());
rt.report_touched(fle.get_location())?;
*i += 1; // poor mans enumerate()
}