added notimestamp option to debug
authorvenaas <venaas>
Fri, 29 Aug 2008 07:57:31 +0000 (07:57 +0000)
committervenaas <venaas@e88ac4ed-0b26-0410-9574-a7f39faa03bf>
Fri, 29 Aug 2008 07:57:31 +0000 (07:57 +0000)
git-svn-id: https://svn.testnett.uninett.no/radsecproxy/trunk@361 e88ac4ed-0b26-0410-9574-a7f39faa03bf

debug.c
debug.h

diff --git a/debug.c b/debug.c
index aac6ac6..80173f5 100644 (file)
--- a/debug.c
+++ b/debug.c
@@ -24,6 +24,7 @@ static char *debug_ident = NULL;
 static uint8_t debug_level = DBG_INFO;
 static FILE *debug_file = NULL;
 static int debug_syslogfacility = 0;
+static uint8_t debug_timestamp = 1;
 
 void debug_init(char *ident) {
     debug_file = stderr;
@@ -48,6 +49,10 @@ void debug_set_level(uint8_t level) {
     }
 }
 
+void debug_no_timestamp() {
+    debug_timestamp = 0;
+}
+
 uint8_t debug_get_level() {
     return debug_level;
 }
@@ -116,8 +121,7 @@ void debug_logit(uint8_t level, const char *format, va_list ap) {
        }
        vsyslog(priority, format, ap);
     } else {
-       timebuf = malloc(256);
-       if (timebuf) {
+       if (debug_timestamp && (timebuf = malloc(256))) {
            gettimeofday(&now, NULL);
            ctime_r(&now.tv_sec, timebuf);
            timebuf[strlen(timebuf) - 1] = '\0';
diff --git a/debug.h b/debug.h
index b4b8787..761a555 100644 (file)
--- a/debug.h
+++ b/debug.h
@@ -17,6 +17,7 @@
 
 void debug_init(char *ident);
 void debug_set_level(uint8_t level);
+void debug_no_timestamp();
 uint8_t debug_get_level();
 void debug(uint8_t level, char *format, ...);
 void debugx(int status, uint8_t level, char *format, ...);