Microseconds in log time.

pull/121/head
nicm 2015-08-29 00:24:44 +00:00
parent d9b3133321
commit 73bd816076
1 changed files with 5 additions and 4 deletions

9
log.c
View File

@ -66,14 +66,15 @@ log_close(void)
void
log_vwrite(const char *msg, va_list ap)
{
char *fmt;
time_t t;
char *fmt;
struct timeval tv;
if (log_file == NULL)
return;
t = time(NULL);
if (asprintf(&fmt, "%lld %s\n", (long long)t, msg) == -1)
gettimeofday(&tv, NULL);
if (asprintf(&fmt, "%lld.%06d %s\n", (long long)tv.tv_sec,
(int)tv.tv_usec, msg) == -1)
exit(1);
if (vfprintf(log_file, fmt, ap) == -1)
exit(1);