xserver: Add timestamps to logfile output.

Add timestamps in seconds derived from clock_monotonic to the log
file.

Signed-off-by: Auke Kok <auke-jan.h.kok@intel.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
This commit is contained in:
Kok, Auke 2010-01-27 11:34:45 -08:00 committed by Keith Packard
parent 0b21a0416b
commit d2322b6309

View File

@ -258,6 +258,14 @@ LogVWrite(int verb, const char *f, va_list args)
{
static char tmpBuffer[1024];
int len = 0;
static Bool newline = TRUE;
if (newline) {
sprintf(tmpBuffer, "[%10.3f] ", GetTimeInMillis() / 1000.0);
len = strlen(tmpBuffer);
if (logFile)
fwrite(tmpBuffer, len, 1, logFile);
}
/*
* Since a va_list can only be processed once, write the string to a
@ -268,6 +276,7 @@ LogVWrite(int verb, const char *f, va_list args)
vsnprintf(tmpBuffer, sizeof(tmpBuffer), f, args);
len = strlen(tmpBuffer);
}
newline = (tmpBuffer[len-1] == '\n');
if ((verb < 0 || logVerbosity >= verb) && len > 0)
fwrite(tmpBuffer, len, 1, stderr);
if ((verb < 0 || logFileVerbosity >= verb) && len > 0) {