- fprintf(stderr, "[%d] %s: ", (int) getpid(), fn);
- vfprintf(stderr, format, args);
+ char buf[1024];
+ struct timeval tv;
+ struct timezone tz;
+
+ vsnprintf(buf, sizeof(buf), format, args);
+ gettimeofday(&tv, &tz);
+ fprintf(stderr, "%llu.%06u [%u] %s: %s",
+ (unsigned long long) tv.tv_sec, (unsigned int) tv.tv_usec,
+ (int) getpid(), fn, buf);