summaryrefslogtreecommitdiff
path: root/source4/lib/ldb
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2009-03-12 10:04:02 +0100
committerStefan Metzmacher <metze@samba.org>2009-03-12 12:04:30 +0100
commit1e4f78cc41d7d44703bea238fee86da618d1587b (patch)
treeed11ffa20c979b1d6bf4a5a6980c7fcf3c669c5c /source4/lib/ldb
parent2fdbafbf5475e8936fb5bc3e3bafc7ee19a9b705 (diff)
downloadsamba-1e4f78cc41d7d44703bea238fee86da618d1587b.tar.gz
samba-1e4f78cc41d7d44703bea238fee86da618d1587b.tar.bz2
samba-1e4f78cc41d7d44703bea238fee86da618d1587b.zip
s4:ldb: setup tevent debug functions on a selfcreated event context
metze
Diffstat (limited to 'source4/lib/ldb')
-rw-r--r--source4/lib/ldb/common/ldb.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/source4/lib/ldb/common/ldb.c b/source4/lib/ldb/common/ldb.c
index f1b28b6819..e17e10dcaa 100644
--- a/source4/lib/ldb/common/ldb.c
+++ b/source4/lib/ldb/common/ldb.c
@@ -48,6 +48,40 @@ static int ldb_context_destructor(void *ptr)
}
/*
+ this is used to catch debug messages from events
+*/
+static void ldb_tevent_debug(void *context, enum tevent_debug_level level,
+ const char *fmt, va_list ap) PRINTF_ATTRIBUTE(3,0);
+
+static void ldb_tevent_debug(void *context, enum tevent_debug_level level,
+ const char *fmt, va_list ap)
+{
+ struct ldb_context = talloc_get_type_abort(context, struct ldb_context);
+ enum ldb_debug_level ldb_level = LDB_DEBUG_FATAL;
+ char *s = NULL;
+
+ switch (level) {
+ case TEVENT_DEBUG_FATAL:
+ ldb_level = LDB_DEBUG_FATAL;
+ break;
+ case TEVENT_DEBUG_ERROR:
+ ldb_level = LDB_DEBUG_ERROR;
+ break;
+ case TEVENT_DEBUG_WARNING:
+ ldb_level = LDB_DEBUG_WARNING;
+ break;
+ case TEVENT_DEBUG_TRACE:
+ ldb_level = LDB_DEBUG_TRACE;
+ break;
+ };
+
+ vasprintf(&s, fmt, ap);
+ if (!s) return;
+ ldb_debug(ldb, ldb_level, "tevent: %s", s);
+ free(s);
+}
+
+/*
initialise a ldb context
The mem_ctx is required
The event_ctx is required
@@ -62,6 +96,7 @@ struct ldb_context *ldb_init(TALLOC_CTX *mem_ctx, struct tevent_context *ev_ctx)
* until we have them all converted */
if (ev_ctx == NULL) {
ev_ctx = tevent_context_init(talloc_autofree_context());
+ tevent_set_debug(ev_ctx, ldb_tevent_debug, ldb);
}
ret = ldb_setup_wellknown_attributes(ldb);