From: Martin Mares Date: Sun, 27 Jul 2008 15:38:14 +0000 (+0200) Subject: Libucw: Cleaned up logging in fb-atomic. X-Git-Tag: holmes-import~360 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=343150ef4c405939d98421d5ac4c09f9565ef35a;p=libucw.git Libucw: Cleaned up logging in fb-atomic. Original patch by Michal, slightly changed by me. --- diff --git a/ucw/Makefile b/ucw/Makefile index e2574f83..bd513a55 100644 --- a/ucw/Makefile +++ b/ucw/Makefile @@ -117,6 +117,7 @@ $(o)/ucw/redblack-test.test: $(o)/ucw/redblack-test $(o)/ucw/basecode.test: $(o)/ucw/basecode $(addprefix $(o)/ucw/fb-,file.test grow.test pool.test socket.test atomic.test \ limfd.test temp.test mem.test buffer.test mmap.test): %.test: %-t +$(o)/ucw/fb-atomic-tt.o: CFLAGS += -DFB_ATOMIC_TRACE $(o)/ucw/url.test: $(o)/ucw/url-t ifdef CONFIG_UCW_THREADS diff --git a/ucw/fb-atomic.c b/ucw/fb-atomic.c index bc350f63..5eca3905 100644 --- a/ucw/fb-atomic.c +++ b/ucw/fb-atomic.c @@ -32,16 +32,30 @@ * or -(expected maximum record length) for variable-sized ones. */ -#define LOCAL_DEBUG - #include "ucw/lib.h" #include "ucw/fastbuf.h" #include "ucw/lfs.h" +#include "ucw/conf.h" #include #include #include +static uns trace; + +static struct cf_section fbatomic_config = { + CF_ITEMS { + CF_UNS("Trace", &trace) + } +}; + +static void CONSTRUCTOR fbatomic_init_config(void) +{ + cf_declare_section("FBAtomic", &fbatomic_config, 1); +} + +#define TRACE(m...) do { if(trace) msg(L_DEBUG, "FB_ATOMIC: " m); } while(0) + struct fb_atomic_file { int fd; int use_count; @@ -79,7 +93,7 @@ fbatomic_spout(struct fastbuf *f) uns written = f->bptr - f->buffer; uns size = f->bufend - f->buffer + F->slack_size; F->slack_size *= 2; - DBG("Reallocating buffer for atomic file %s with slack %d", f->name, F->slack_size); + TRACE("Reallocating buffer for atomic file %s with slack %d", f->name, F->slack_size); f->buffer = xrealloc(f->buffer, size); f->bufend = f->buffer + size; f->bptr = f->buffer + written; @@ -145,6 +159,9 @@ int main(int argc UNUSED, char **argv UNUSED) { struct fastbuf *f, *g; + // Always trace in the test + trace = 1; + msg(L_INFO, "Testing block writes"); f = fbatomic_open("test", NULL, 16, 4); for (u32 i=0; i<17; i++) diff --git a/ucw/fb-atomic.t b/ucw/fb-atomic.t index be70c63b..6db6c06a 100644 --- a/ucw/fb-atomic.t +++ b/ucw/fb-atomic.t @@ -3,5 +3,5 @@ Run: ../obj/ucw/fb-atomic-t 2>&1 | sed -e 's/^\(.\) [^ ]* [^ ]* /\1 /' Out: I Testing block writes I Testing interleaved var-size writes - D Reallocating buffer for atomic file test2 with slack 10 - D Reallocating buffer for atomic file test2 with slack 10 + D FB_ATOMIC: Reallocating buffer for atomic file test2 with slack 10 + D FB_ATOMIC: Reallocating buffer for atomic file test2 with slack 10