include milliseconds in log timestamps

This commit is contained in:
katianderic 2020-03-07 22:55:44 +01:00
parent 126172220f
commit 5d6c2514fd

View file

@ -42,16 +42,16 @@
static void
debugf( const char* format, va_list ap )
{
struct timeval tv;
struct timezone tz;
gettimeofday( &tv, &tz );
struct timespec tp = {0};
int res = clock_gettime( CLOCK_REALTIME, &tp );
XP_ASSERT( 0 == res );
struct tm* timp = localtime( &tp.tv_sec );
struct tm* timp = localtime( &tv.tv_sec );
fprintf( stderr, "<%d:%lx> %.2d:%.2d:%.2d:%03ld ", getpid(),
pthread_self(), timp->tm_hour, timp->tm_min, timp->tm_sec,
tp.tv_nsec / 1000000 );
fprintf( stderr, "<%d:%lx>%.2d:%.2d:%.2d:", getpid(),
pthread_self(), timp->tm_hour, timp->tm_min, timp->tm_sec );
vfprintf(stderr, format, ap );
vfprintf( stderr, format, ap );
fprintf( stderr, "%c", '\n' );
}