Index: xorg-server-1.6.0/os/log.c =================================================================== --- xorg-server-1.6.0.orig/os/log.c 2009-02-25 11:12:13.000000000 -0800 +++ xorg-server-1.6.0/os/log.c 2009-03-24 13:13:40.000000000 -0700 @@ -313,6 +313,28 @@ { const char *s = X_UNKNOWN_STRING; char *tmpBuf = NULL; + struct timeval time; + time_t tv_sec; + suseconds_t tv_usec; + static Bool first = TRUE; + static time_t start_tv_sec; + static suseconds_t start_usec; + int diff_sec, diff_usec; + + gettimeofday(&time, NULL); + tv_sec = time.tv_sec; + tv_usec = time.tv_usec; + if (first == TRUE) { + start_tv_sec = tv_sec; + start_usec = tv_usec; + first = FALSE; + } + diff_sec = (int)difftime(tv_sec, start_tv_sec); + diff_usec = (tv_usec - start_usec); + if (diff_usec < 0) { + diff_sec--; + diff_usec += 1000000; + } /* Ignore verbosity for X_ERROR */ if (logVerbosity >= verb || logFileVerbosity >= verb || type == X_ERROR) { @@ -357,14 +379,13 @@ /* * Prefix the format string with the message type. We do it this way * so that LogVWrite() is only called once per message. + * Prefix the whole with timestamp. */ if (s) { - tmpBuf = malloc(strlen(format) + strlen(s) + 1 + 1); + if (asprintf(&tmpBuf, "[%5d.%06d] %s %s", diff_sec, diff_usec, s, format) < 0 || !tmpBuf) { /* Silently return if malloc fails here. */ - if (!tmpBuf) return; - sprintf(tmpBuf, "%s ", s); - strcat(tmpBuf, format); + } LogVWrite(verb, tmpBuf, args); free(tmpBuf); } else