summaryrefslogtreecommitdiffstats
path: root/test/logging.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 16:49:38 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 16:49:38 +0000
commitbd8128271ad96c97ddaf5c86915a981ddbff86c6 (patch)
tree19fb138628afa53c660a2db82488d0b703a52fa7 /test/logging.c
parentInitial commit. (diff)
downloadtdb-upstream.tar.xz
tdb-upstream.zip
Adding upstream version 1.4.10.upstream/1.4.10upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--test/logging.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/test/logging.c b/test/logging.c
new file mode 100644
index 0000000..dfab486
--- /dev/null
+++ b/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 };