summaryrefslogtreecommitdiffstats
path: root/ctdb/lib/tdb/test/logging.c
diff options
context:
space:
mode:
authorAmitay Isaacs <amitay@gmail.com>2013-05-29 14:05:50 +1000
committerAmitay Isaacs <amitay@gmail.com>2013-05-29 17:47:16 +1000
commitfe1fc55c616f175a3ebdd8edb64dca0430c149d7 (patch)
treef09d1b7f8b594412a109442822a6a55f6a639dbd /ctdb/lib/tdb/test/logging.c
parent803416d9787361f61d7d0a22618df45d5b7af4f3 (diff)
downloadsamba-fe1fc55c616f175a3ebdd8edb64dca0430c149d7.tar.gz
samba-fe1fc55c616f175a3ebdd8edb64dca0430c149d7.tar.xz
samba-fe1fc55c616f175a3ebdd8edb64dca0430c149d7.zip
tdb: Sync to tdb 1.2.11 from upstream
(This used to be ctdb commit bb3a32ec055432afc7225c9fd7504fb187694bda)
Diffstat (limited to 'ctdb/lib/tdb/test/logging.c')
-rw-r--r--ctdb/lib/tdb/test/logging.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/ctdb/lib/tdb/test/logging.c b/ctdb/lib/tdb/test/logging.c
new file mode 100644
index 00000000000..dfab4868d25
--- /dev/null
+++ b/ctdb/lib/tdb/test/logging.c
@@ -0,0 +1,33 @@
+#include "logging.h"
+#include "tap-interface.h"
+#include <stdarg.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+
+bool suppress_logging = false;
+const char *log_prefix = "";
+
+/* Turn log messages into tap diag messages. */
+static void taplog(struct tdb_context *tdb,
+ enum tdb_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 tdb_logging_context taplogctx = { taplog, NULL };