[btr:] Add btr_log_tree().
authorAndre Noll <maan@systemlinux.org>
Sun, 3 Jan 2010 03:12:01 +0000 (04:12 +0100)
committerAndre Noll <maan@systemlinux.org>
Sun, 3 Jan 2010 03:12:01 +0000 (04:12 +0100)
buffer_tree.c
buffer_tree.h
filter.c

index cd3a3c7..5d8e33f 100644 (file)
@@ -371,3 +371,20 @@ bool btr_eof(struct btr_node *btrn)
 
        return (len == 0 && btr_no_parent(btrn));
 }
+
+void log_tree_recursively(struct btr_node *btrn, int loglevel, int depth)
+{
+       struct btr_node *ch;
+       const char spaces[] = "                 ", *space = spaces + 16 - depth;
+
+       if (depth > 16)
+               return;
+       para_log(loglevel, "%s%s\n", space, btrn->name);
+       FOR_EACH_CHILD(ch, btrn)
+               log_tree_recursively(ch, loglevel, depth + 1);
+}
+
+void btr_log_tree(struct btr_node *btrn, int loglevel)
+{
+       return log_tree_recursively(btrn, loglevel, 0);
+}
index 589bde2..77343f8 100644 (file)
@@ -21,3 +21,4 @@ void btr_pushdown(struct btr_node *btrn);
 void *btr_context(struct btr_node *btrn);
 void btr_merge(struct btr_node *btrn, size_t dest_size);
 bool btr_eof(struct btr_node *btrn);
+void btr_log_tree(struct btr_node *btrn, int loglevel);
index 88a0bd7..ed8cde4 100644 (file)
--- a/filter.c
+++ b/filter.c
@@ -192,6 +192,7 @@ static int __noreturn main_btr(void)
 
        s.default_timeout.tv_sec = 1;
        s.default_timeout.tv_usec = 0;
+       btr_log_tree(sit->btrn, LL_INFO);
        ret = schedule(&s);
 err:
        if (ret < 0)