1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-21 18:04:06 +03:00
samba-mirror/lib/tdb/test/logging.c
Rusty Russell 8fa345d952 tdb: wean CCAN-style unit tests off of tap.
We could use subunit, but that's overkill.  Just print messages when
we fail, and use exit status.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2012-02-14 14:45:19 +10:30

34 lines
716 B
C

#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 };