]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
Add timestamps to debug output.
authorVolker Lendecke <vl@samba.org>
Tue, 17 Apr 2007 15:59:39 +0000 (17:59 +0200)
committerVolker Lendecke <vl@samba.org>
Tue, 17 Apr 2007 15:59:39 +0000 (17:59 +0200)
(This used to be ctdb commit 197a02384bd2ca42dfff4c0357175424d2321e9c)

ctdb/Makefile.in
ctdb/common/ctdb.c
ctdb/include/includes.h
ctdb/lib/util/debug.c [new file with mode: 0644]
ctdb/lib/util/debug.h [new file with mode: 0644]

index 14e4487e6d3657781b68e0f7a7fc161cfeba6dd4..7729875f4e3494aa8c4b167855b65fa58126b53e 100644 (file)
@@ -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
 
index a69cbdbee726a1da1f9eb97b54038828c17e0ee6..57ebd131da1495313ec6afdd1a605b215eead329 100644 (file)
@@ -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:
index 5d3207820cb08904b9ee56988e25ed5f1ad68825..bffc66b358b597c1c9138bb70de10823337d416e 100644 (file)
@@ -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 (file)
index 0000000..a322901
--- /dev/null
@@ -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 (file)
index 0000000..bc1e8f9
--- /dev/null
@@ -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, ...);