s3:include: remove typedef user_struct
[Samba/gebeck_regimport.git] / lib / tdb2 / test / logging.c
blob86fc152bab309d03abafed6bc86e0c1f142d3398
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include "tap-interface.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++;