summaryrefslogtreecommitdiffstats
path: root/source4/lib
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2006-01-09 18:25:06 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:49:56 -0500
commit3c13509c06b5ff969e51f7cb552e525fc627c1ed (patch)
tree6e2ff46daac0ac08adb5b5b7fa8a0dd58d3c0d2d /source4/lib
parent6d0beb088565abeaca53e4346dc94940c7de398e (diff)
downloadsamba-3c13509c06b5ff969e51f7cb552e525fc627c1ed.tar.gz
samba-3c13509c06b5ff969e51f7cb552e525fc627c1ed.tar.xz
samba-3c13509c06b5ff969e51f7cb552e525fc627c1ed.zip
r12798: print timestamps into the log file, this is not nice code,
but it works for now metze (This used to be commit ec7dbb5a98c112e86399ffcff14eb42c99d8e31d)
Diffstat (limited to 'source4/lib')
-rw-r--r--source4/lib/debug.c32
1 files changed, 30 insertions, 2 deletions
diff --git a/source4/lib/debug.c b/source4/lib/debug.c
index a775c46854..d0288f7ddc 100644
--- a/source4/lib/debug.c
+++ b/source4/lib/debug.c
@@ -21,6 +21,7 @@
#include "includes.h"
#include "system/filesys.h"
+#include "system/time.h"
#include "dynconfig.h"
/* this global variable determines what messages are printed */
@@ -44,6 +45,16 @@ static struct {
the backend for debug messages. Note that the DEBUG() macro has already
ensured that the log level has been met before this is called
*/
+void do_debug_header(int level)
+{
+ log_timestring(level);
+ log_task_id();
+}
+
+/*
+ the backend for debug messages. Note that the DEBUG() macro has already
+ ensured that the log level has been met before this is called
+*/
void do_debug(const char *format, ...)
{
va_list ap;
@@ -59,8 +70,6 @@ void do_debug(const char *format, ...)
vasprintf(&s, format, ap);
va_end(ap);
- log_task_id();
-
write(state.fd, s, strlen(s));
free(s);
}
@@ -153,6 +162,24 @@ void print_suspicious_usage(const char* from, const char* info)
}
}
+void log_timestring(int level)
+{
+ char *t = NULL;
+ char *s = NULL;
+
+ if (state.logtype != DEBUG_FILE) return;
+
+ t = timestring(NULL, time(NULL));
+ if (!t) return;
+
+ asprintf(&s, "[%s, %d]\n", t, level);
+ talloc_free(t);
+ if (!s) return;
+
+ write(state.fd, s, strlen(s));
+ free(s);
+}
+
uint32_t get_task_id(void)
{
if (debug_handlers.ops.get_task_id) {
@@ -167,6 +194,7 @@ void log_task_id(void)
debug_handlers.ops.log_task_id(state.fd);
}
}
+
/*
register a set of debug handlers.
*/