Debugging: millisecond timestamps. Bug 2102
[exim.git] / src / src / debug.c
index 8c414d0f967c79e7bb50a4ab8f2695bdca660033..f6c8b2f62eb7cd61480da828512aa2cb97f44895 100644 (file)
@@ -182,10 +182,16 @@ if (debug_ptr == debug_buffer)
   {
   DEBUG(D_timestamp)
     {
-    time_t now = time(NULL);
-    struct tm *t = timestamps_utc? gmtime(&now) : localtime(&now);
-    debug_ptr += sprintf(CS debug_ptr, "%02d:%02d:%02d ", t->tm_hour, t->tm_min,
-      t->tm_sec);
+    struct timeval now;
+    time_t tmp;
+    struct tm * t;
+
+    gettimeofday(&now, NULL);
+    tmp = now.tv_sec;
+    t = timestamps_utc ? gmtime(&now) : localtime(&now);
+    debug_ptr += sprintf(CS debug_ptr,
+      LOGGING(millisec) ? "%02d:%02d:%02d.%03d " : "%02d:%02d:%02d ",
+      t->tm_hour, t->tm_min, t->tm_sec, now.tv_usec/1000);
     }
 
   DEBUG(D_pid)