Linux Archive

Linux Archive (http://www.linux-archive.org/)
-   Ubuntu Kernel Team (http://www.linux-archive.org/ubuntu-kernel-team/)
-   -   Make loader log time with milliseconds (part of #524980). (http://www.linux-archive.org/ubuntu-kernel-team/288713-make-loader-log-time-milliseconds-part-524980-a.html)

Ales Kozumplik 12-01-2009 01:42 PM

Make loader log time with milliseconds (part of #524980).
 
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@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list

Chris Lumens 12-01-2009 04:01 PM

Make loader log time with milliseconds (part of #524980).
 
> @@ -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;

Stylistically, I like putting all the variable declarations before
places where we start using them, but I guess now I'm just being really
picky.

- Chris

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


All times are GMT. The time now is 04:47 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.