summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ctdb/lib/util/db_wrap.c20
-rw-r--r--ctdb/lib/util/debug.c14
-rw-r--r--ctdb/lib/util/debug.h1
3 files changed, 29 insertions, 6 deletions
diff --git a/ctdb/lib/util/db_wrap.c b/ctdb/lib/util/db_wrap.c
index 2841f513cc..f4e89cf270 100644
--- a/ctdb/lib/util/db_wrap.c
+++ b/ctdb/lib/util/db_wrap.c
@@ -44,6 +44,18 @@ static int tdb_wrap_destructor(struct tdb_wrap *w)
return 0;
}
+static void log_fn(struct tdb_context *tdb, enum tdb_debug_level level, const char *fmt, ...)
+{
+ if (level <= TDB_DEBUG_ERROR) {
+ va_list ap;
+
+ va_start(ap, fmt);
+ do_debug_v(fmt, ap);
+ va_end(ap);
+ }
+}
+
+
/*
wrapped connection to a tdb database
to close just talloc_free() the tdb_wrap pointer
@@ -53,6 +65,10 @@ struct tdb_wrap *tdb_wrap_open(TALLOC_CTX *mem_ctx,
int open_flags, mode_t mode)
{
struct tdb_wrap *w;
+ struct tdb_logging_context log_ctx;
+
+ log_ctx.log_fn = log_fn;
+ log_ctx.log_private = NULL;
for (w=tdb_list;w;w=w->next) {
if (strcmp(name, w->name) == 0) {
@@ -67,8 +83,8 @@ struct tdb_wrap *tdb_wrap_open(TALLOC_CTX *mem_ctx,
w->name = talloc_strdup(w, name);
- w->tdb = tdb_open(name, hash_size, tdb_flags,
- open_flags, mode);
+ w->tdb = tdb_open_ex(name, hash_size, tdb_flags,
+ open_flags, mode, &log_ctx, NULL);
if (w->tdb == NULL) {
talloc_free(w);
return NULL;
diff --git a/ctdb/lib/util/debug.c b/ctdb/lib/util/debug.c
index 78d465d52b..c1f1c91410 100644
--- a/ctdb/lib/util/debug.c
+++ b/ctdb/lib/util/debug.c
@@ -22,17 +22,14 @@
#include <unistd.h>
-void do_debug(const char *format, ...)
+void do_debug_v(const char *format, va_list ap)
{
struct timeval t;
- va_list ap;
char *s = NULL;
struct tm *tm;
char tbuf[100];
- va_start(ap, format);
vasprintf(&s, format, ap);
- va_end(ap);
t = timeval_current();
tm = localtime(&t.tv_sec);
@@ -43,3 +40,12 @@ void do_debug(const char *format, ...)
fflush(stderr);
free(s);
}
+
+void do_debug(const char *format, ...)
+{
+ va_list ap;
+
+ va_start(ap, format);
+ do_debug_v(format, ap);
+ va_end(ap);
+}
diff --git a/ctdb/lib/util/debug.h b/ctdb/lib/util/debug.h
index 510034ef9a..ce454bc668 100644
--- a/ctdb/lib/util/debug.h
+++ b/ctdb/lib/util/debug.h
@@ -17,4 +17,5 @@
along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
+void do_debug_v(const char *format, va_list ap);
void do_debug(const char *format, ...) PRINTF_ATTRIBUTE(1, 2);