]> arthur.barton.de Git - netatalk.git/commitdiff
Change time format to also output microseconds before-dbd-overhaul
authorfranklahm <franklahm>
Mon, 20 Apr 2009 14:53:20 +0000 (14:53 +0000)
committerfranklahm <franklahm>
Mon, 20 Apr 2009 14:53:20 +0000 (14:53 +0000)
libatalk/util/logger.c

index 5499656779c5d79796b23010301b17bb1f9a94df..ed1341efb4d4d5b0928065a9cae12fdaeb895ff7 100644 (file)
@@ -30,6 +30,7 @@
 #include <fcntl.h>
 #include <sys/uio.h>
 #include <unistd.h>
+#include <sys/time.h>
 #include <time.h>
 #include <ctype.h>
 
@@ -155,18 +156,21 @@ static void generate_message_details(char *message_details_buffer,
     char   *ptr = message_details_buffer;
     int    templen;
     int    len = message_details_buffer_length;
+    struct timeval tv;
 
     *ptr = 0;
 
-    /* Print date */
-    time_t thetime;
-    time(&thetime);
-
-    strftime(ptr, len, "%b %d %H:%M:%S ", localtime(&thetime));
+    /* Print time */
+    gettimeofday(&tv, NULL);
+    strftime(ptr, len, "%b %d %H:%M:%S.", localtime(&tv.tv_sec));
     templen = strlen(ptr);
     len -= templen;
     ptr += templen;
 
+    templen = snprintf(ptr, len, "%06u ", (int)tv.tv_usec);
+    len -= templen;
+    ptr += templen;
+
     /* Process name */
     strncpy(ptr, log_config.processname, len);
     templen = strlen(ptr);