summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ctdb/Makefile.in2
-rw-r--r--ctdb/common/ctdb.c5
-rw-r--r--ctdb/include/includes.h3
-rw-r--r--ctdb/lib/util/debug.c40
-rw-r--r--ctdb/lib/util/debug.h21
5 files changed, 67 insertions, 4 deletions
diff --git a/ctdb/Makefile.in b/ctdb/Makefile.in
index 14e4487e6d..7729875f4e 100644
--- a/ctdb/Makefile.in
+++ b/ctdb/Makefile.in
@@ -22,7 +22,7 @@ EVENTS_OBJ = lib/events/events.o lib/events/events_standard.o
CTDB_COMMON_OBJ = common/ctdb.o common/ctdb_daemon.o common/ctdb_client.o common/ctdb_io.o common/util.o common/ctdb_util.o \
common/ctdb_call.o common/ctdb_ltdb.o common/ctdb_lockwait.o common/ctdb_message.o \
- common/cmdline.o lib/util/idtree.o lib/util/db_wrap.o
+ common/cmdline.o lib/util/idtree.o lib/util/db_wrap.o lib/util/debug.o
CTDB_TCP_OBJ = tcp/tcp_connect.o tcp/tcp_io.o tcp/tcp_init.o
diff --git a/ctdb/common/ctdb.c b/ctdb/common/ctdb.c
index a69cbdbee7..57ebd131da 100644
--- a/ctdb/common/ctdb.c
+++ b/ctdb/common/ctdb.c
@@ -215,8 +215,9 @@ void ctdb_recv_pkt(struct ctdb_context *ctdb, uint8_t *data, uint32_t length)
return;
}
- DEBUG(3,(__location__ " ctdb request of type %d length %d from node %d to %d\n",
- hdr->operation, hdr->length, hdr->srcnode, hdr->destnode));
+ DEBUG(3,(__location__ " ctdb request %d of type %d length %d from "
+ "node %d to %d\n", hdr->reqid, hdr->operation, hdr->length,
+ hdr->srcnode, hdr->destnode));
switch (hdr->operation) {
case CTDB_REQ_CALL:
diff --git a/ctdb/include/includes.h b/ctdb/include/includes.h
index 5d3207820c..bffc66b358 100644
--- a/ctdb/include/includes.h
+++ b/ctdb/include/includes.h
@@ -6,6 +6,7 @@
#include "idtree.h"
#include "ctdb.h"
#include "lib/util/dlinklist.h"
+#include "lib/util/debug.h"
typedef bool BOOL;
@@ -14,7 +15,7 @@ typedef bool BOOL;
extern int LogLevel;
-#define DEBUG(lvl, x) if ((lvl) <= LogLevel) (printf x)
+#define DEBUG(lvl, x) if ((lvl) <= LogLevel) (do_debug x)
#define _PUBLIC_
diff --git a/ctdb/lib/util/debug.c b/ctdb/lib/util/debug.c
new file mode 100644
index 0000000000..a3229015ca
--- /dev/null
+++ b/ctdb/lib/util/debug.c
@@ -0,0 +1,40 @@
+/*
+ Unix SMB/CIFS implementation.
+ ctdb debug functions
+ Copyright (C) Volker Lendecke 2007
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include "includes.h"
+#include "system/time.h"
+#include <unistd.h>
+
+void do_debug(const char *format, ...)
+{
+ struct timeval tm;
+ va_list ap;
+ char *s = NULL;
+
+ va_start(ap, format);
+ vasprintf(&s, format, ap);
+ va_end(ap);
+
+ gettimeofday(&tm, NULL);
+ printf("%-8.8d.%-6.6d [%d]: %s", (int)tm.tv_sec, (int)tm.tv_usec,
+ (int)getpid(), s);
+ fflush(stdout);
+ free(s);
+}
diff --git a/ctdb/lib/util/debug.h b/ctdb/lib/util/debug.h
new file mode 100644
index 0000000000..bc1e8f9423
--- /dev/null
+++ b/ctdb/lib/util/debug.h
@@ -0,0 +1,21 @@
+/*
+ Unix SMB/CIFS implementation.
+ ctdb debug functions
+ Copyright (C) Volker Lendecke 2007
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+void do_debug(const char *format, ...);