diff options
author | Rusty Russell <rusty@rustcorp.com.au> | 2011-09-14 07:24:13 +0930 |
---|---|---|
committer | Rusty Russell <rusty@rustcorp.com.au> | 2011-09-14 07:24:13 +0930 |
commit | 9660546a18cc9af508e6e594349d869bdcefafb2 (patch) | |
tree | d4730be4e2663201ed8f6c6820180e930bb40d89 /lib/tdb2/test/tdb1-logging.c | |
parent | bfcd0ebd980eb5ebc56e6b57fd158c2fad89fc78 (diff) | |
download | samba-9660546a18cc9af508e6e594349d869bdcefafb2.tar.gz samba-9660546a18cc9af508e6e594349d869bdcefafb2.tar.bz2 samba-9660546a18cc9af508e6e594349d869bdcefafb2.zip |
tdb2: test: import tdb1's tests.
The main change is to s/tdb/tdb1_/ everywhere.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
(Imported from CCAN commit fab544c24c1ad6523f95893abcaec4e6cce6c2b4)
Diffstat (limited to 'lib/tdb2/test/tdb1-logging.c')
-rw-r--r-- | lib/tdb2/test/tdb1-logging.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/lib/tdb2/test/tdb1-logging.c b/lib/tdb2/test/tdb1-logging.c new file mode 100644 index 0000000000..43ce07b27c --- /dev/null +++ b/lib/tdb2/test/tdb1-logging.c @@ -0,0 +1,30 @@ +#include "tdb1-logging.h" +#include <ccan/tap/tap.h> +#include <stdarg.h> +#include <stdlib.h> +#include <string.h> +#include <stdio.h> + +/* Turn log messages into tap diag messages. */ +static void taplog(struct tdb1_context *tdb, + enum tdb1_debug_level level, + const char *fmt, ...) +{ + va_list ap; + char line[200]; + + if (suppress_logging) + return; + + va_start(ap, fmt); + vsprintf(line, fmt, ap); + va_end(ap); + + /* Strip trailing \n: diag adds it. */ + if (line[0] && line[strlen(line)-1] == '\n') + diag("%s%.*s", log_prefix, (unsigned)strlen(line)-1, line); + else + diag("%s%s", log_prefix, line); +} + +struct tdb1_logging_context taplogctx = { taplog, NULL }; |