From 33c1c9a440ba25e8c4c4988d8811402fb29afb0f Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Sun, 3 Jan 2010 04:12:01 +0100 Subject: [PATCH] [btr:] Add btr_log_tree(). --- buffer_tree.c | 17 +++++++++++++++++ buffer_tree.h | 1 + filter.c | 1 + 3 files changed, 19 insertions(+) diff --git a/buffer_tree.c b/buffer_tree.c index cd3a3c78..5d8e33fc 100644 --- a/buffer_tree.c +++ b/buffer_tree.c @@ -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); +} diff --git a/buffer_tree.h b/buffer_tree.h index 589bde27..77343f83 100644 --- a/buffer_tree.h +++ b/buffer_tree.h @@ -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); diff --git a/filter.c b/filter.c index 88a0bd75..ed8cde41 100644 --- 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) -- 2.39.5