[master] Make loader log time with milliseconds (part of #524980).

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is to make the anaconda.log have consistent entries from loader and from stage 2.
---
 loader/log.c |   27 +++++++++++++++------------
 1 files changed, 15 insertions(+), 12 deletions(-)

diff --git a/loader/log.c b/loader/log.c
index 2872fe8..c92222a 100644
--- a/loader/log.c
+++ b/loader/log.c
@@ -29,6 +29,7 @@
 #include <stdlib.h>
 #include <time.h>
 #include <unistd.h>
+#include <sys/time.h>
 
 #include "log.h"
 
@@ -37,33 +38,35 @@ static FILE * file_logfile = NULL;
 static int minLevel = INFO;
 
 static void printLogHeader(int level, FILE *outfile) {
-    time_t current_time = time(NULL);
-    struct tm *t = gmtime (&current_time);
+    struct timeval current_time;
+    gettimeofday(&current_time, NULL);
+    struct tm *t = gmtime(&current_time.tv_sec);
+    int msecs = current_time.tv_usec / 1000;
 
     switch (level) {
         case DEBUGLVL:
-            fprintf (outfile, "%02d:%02d:%02d DEBUG   : ", t->tm_hour,
-                     t->tm_min, t->tm_sec);
+            fprintf (outfile, "%02d:%02d:%02d,%03d DEBUG   : ", t->tm_hour,
+                     t->tm_min, t->tm_sec, msecs);
             break;
 
         case INFO:
-            fprintf (outfile, "%02d:%02d:%02d INFO    : ", t->tm_hour,
-                     t->tm_min, t->tm_sec);
+            fprintf (outfile, "%02d:%02d:%02d,%03d INFO    : ", t->tm_hour,
+                     t->tm_min, t->tm_sec, msecs);
             break;
 
         case WARNING:
-            fprintf (outfile, "%02d:%02d:%02d WARNING : ", t->tm_hour,
-                     t->tm_min, t->tm_sec);
+            fprintf (outfile, "%02d:%02d:%02d,%03d WARNING : ", t->tm_hour,
+                     t->tm_min, t->tm_sec, msecs);
             break;
 
         case ERROR:
-            fprintf (outfile, "%02d:%02d:%02d ERROR   : ", t->tm_hour,
-                     t->tm_min, t->tm_sec);
+            fprintf (outfile, "%02d:%02d:%02d,%03d ERROR   : ", t->tm_hour,
+                     t->tm_min, t->tm_sec, msecs);
             break;
 
         case CRITICAL:
-            fprintf (outfile, "%02d:%02d:%02d CRITICAL: ", t->tm_hour,
-                     t->tm_min, t->tm_sec);
+            fprintf (outfile, "%02d:%02d:%02d,%03d CRITICAL: ", t->tm_hour,
+                     t->tm_min, t->tm_sec, msecs);
             break;
     }
 }
-- 
1.6.2.5

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list

[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux