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:
parent
0b21a0416b
commit
d2322b6309
9
os/log.c
9
os/log.c
|
@ -258,6 +258,14 @@ LogVWrite(int verb, const char *f, va_list args)
|
||||||
{
|
{
|
||||||
static char tmpBuffer[1024];
|
static char tmpBuffer[1024];
|
||||||
int len = 0;
|
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
|
* 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);
|
vsnprintf(tmpBuffer, sizeof(tmpBuffer), f, args);
|
||||||
len = strlen(tmpBuffer);
|
len = strlen(tmpBuffer);
|
||||||
}
|
}
|
||||||
|
newline = (tmpBuffer[len-1] == '\n');
|
||||||
if ((verb < 0 || logVerbosity >= verb) && len > 0)
|
if ((verb < 0 || logVerbosity >= verb) && len > 0)
|
||||||
fwrite(tmpBuffer, len, 1, stderr);
|
fwrite(tmpBuffer, len, 1, stderr);
|
||||||
if ((verb < 0 || logFileVerbosity >= verb) && len > 0) {
|
if ((verb < 0 || logFileVerbosity >= verb) && len > 0) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user