s3:registry: do not use regdb functions during db upgrade
[Samba/gebeck_regimport.git] / lib / tdb2 / test / logging.c
blob6927592b8a26cc06384b11a5accaa80fe65f234e
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <ccan/tap/tap.h>
4 #include "logging.h"
6 unsigned tap_log_messages;
7 const char *log_prefix = "";
8 char *log_last = NULL;
9 bool suppress_logging;
11 union tdb_attribute tap_log_attr = {
12 .log = { .base = { .attr = TDB_ATTRIBUTE_LOG },
13 .fn = tap_log_fn }
16 void tap_log_fn(struct tdb_context *tdb,
17 enum tdb_log_level level,
18 enum TDB_ERROR ecode,
19 const char *message, void *priv)
21 if (suppress_logging)
22 return;
24 diag("tdb log level %u: %s: %s%s",
25 level, tdb_errorstr(ecode), log_prefix, message);
26 if (log_last)
27 free(log_last);
28 log_last = strdup(message);
29 tap_log_messages++;