Rev 723: ensure tdb log messages appear in ctdbd logs in http://samba.org/~tridge/ctdb

tridge at samba.org tridge at samba.org
Sun Jan 6 01:35:50 GMT 2008


------------------------------------------------------------
revno: 723
revision-id:tridge at samba.org-20080106013549-hkt71y7g65cr3g14
parent: tridge at samba.org-20080106013357-vgve1hciv32kp6v4
committer: Andrew Tridgell <tridge at samba.org>
branch nick: tridge.stable
timestamp: Sun 2008-01-06 12:35:49 +1100
message:
  ensure tdb log messages appear in ctdbd logs
modified:
  lib/util/db_wrap.c             db_wrap.c-20070125041102-mfc39bu6uof09lw6-1
  lib/util/debug.c               debug.c-20070417155854-2i3crb0irl716qft-1
  lib/util/debug.h               debug.h-20070417155854-2i3crb0irl716qft-2
=== modified file 'lib/util/db_wrap.c'
--- a/lib/util/db_wrap.c	2007-07-10 05:29:31 +0000
+++ b/lib/util/db_wrap.c	2008-01-06 01:35:49 +0000
@@ -44,6 +44,18 @@
 	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 @@
 			       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 @@
 
 	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;

=== modified file 'lib/util/debug.c'
--- a/lib/util/debug.c	2007-08-07 03:40:13 +0000
+++ b/lib/util/debug.c	2008-01-06 01:35:49 +0000
@@ -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 @@
 	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);
+}

=== modified file 'lib/util/debug.h'
--- a/lib/util/debug.h	2007-07-10 05:29:31 +0000
+++ b/lib/util/debug.h	2008-01-06 01:35:49 +0000
@@ -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);



More information about the samba-cvs mailing list