summaryrefslogtreecommitdiff
path: root/lib/ldb/common
diff options
context:
space:
mode:
Diffstat (limited to 'lib/ldb/common')
-rw-r--r--lib/ldb/common/ldb.c9
-rw-r--r--lib/ldb/common/ldb_debug.c16
2 files changed, 16 insertions, 9 deletions
diff --git a/lib/ldb/common/ldb.c b/lib/ldb/common/ldb.c
index 779bed8d23..887a8967b1 100644
--- a/lib/ldb/common/ldb.c
+++ b/lib/ldb/common/ldb.c
@@ -60,7 +60,6 @@ static void ldb_tevent_debug(void *context, enum tevent_debug_level level,
{
struct ldb_context *ldb = talloc_get_type(context, struct ldb_context);
enum ldb_debug_level ldb_level = LDB_DEBUG_FATAL;
- char *s = NULL;
switch (level) {
case TEVENT_DEBUG_FATAL:
@@ -77,10 +76,10 @@ static void ldb_tevent_debug(void *context, enum tevent_debug_level level,
break;
};
- vasprintf(&s, fmt, ap);
- if (!s) return;
- ldb_debug(ldb, ldb_level, "tevent: %s", s);
- free(s);
+ /* There isn't a tevent: prefix here because to add it means
+ * actually printing the string, and most of the time we don't
+ * want to show it */
+ ldb_vdebug(ldb, ldb_level, fmt, ap);
}
/*
diff --git a/lib/ldb/common/ldb_debug.c b/lib/ldb/common/ldb_debug.c
index 6aa58ccf71..d5e9e7aa29 100644
--- a/lib/ldb/common/ldb_debug.c
+++ b/lib/ldb/common/ldb_debug.c
@@ -79,11 +79,10 @@ int ldb_set_debug_stderr(struct ldb_context *ldb)
}
/*
- log a message
+ log a message (va_list helper for ldb_tevent_debug)
*/
-void ldb_debug(struct ldb_context *ldb, enum ldb_debug_level level, const char *fmt, ...)
+void ldb_vdebug(struct ldb_context *ldb, enum ldb_debug_level level, const char *fmt, va_list ap)
{
- va_list ap;
if (ldb->debug_ops.debug == NULL) {
if (ldb->flags & LDB_FLG_ENABLE_TRACING) {
ldb_set_debug(ldb, ldb_debug_stderr_all, ldb);
@@ -91,8 +90,17 @@ void ldb_debug(struct ldb_context *ldb, enum ldb_debug_level level, const char *
ldb_set_debug_stderr(ldb);
}
}
- va_start(ap, fmt);
ldb->debug_ops.debug(ldb->debug_ops.context, level, fmt, ap);
+}
+
+/*
+ log a message
+*/
+void ldb_debug(struct ldb_context *ldb, enum ldb_debug_level level, const char *fmt, ...)
+{
+ va_list ap;
+ va_start(ap, fmt);
+ ldb_vdebug(ldb, level, fmt, ap);
va_end(ap);
}