mirror of
https://github.com/jorisvink/kore
synced 2025-03-09 04:29:02 -04:00
Log timestamps in UTC for, add milliseconds.
This is when using the normal foreground logs or a specified logfile.
This commit is contained in:
parent
b6ec4081d5
commit
41511c1683
16
src/log.c
16
src/log.c
@ -130,10 +130,10 @@ log_from_worker(struct kore_msg *msg, const void *data)
|
||||
static void
|
||||
log_print(int prio, const char *fmt, ...)
|
||||
{
|
||||
struct tm *t;
|
||||
time_t now;
|
||||
va_list args;
|
||||
char tbuf[32];
|
||||
struct tm *t;
|
||||
struct timespec ts;
|
||||
va_list args;
|
||||
char tbuf[32];
|
||||
|
||||
va_start(args, fmt);
|
||||
|
||||
@ -146,11 +146,11 @@ log_print(int prio, const char *fmt, ...)
|
||||
break;
|
||||
}
|
||||
|
||||
time(&now);
|
||||
t = localtime(&now);
|
||||
(void)clock_gettime(CLOCK_REALTIME, &ts);
|
||||
t = gmtime(&ts.tv_sec);
|
||||
|
||||
if (strftime(tbuf, sizeof(tbuf), "%y-%m-%d %H:%M:%S", t) > 0)
|
||||
fprintf(fp, "%s ", tbuf);
|
||||
if (strftime(tbuf, sizeof(tbuf), "%Y-%m-%d %H:%M:%S", t) > 0)
|
||||
fprintf(fp, "%s.%ld UTC ", tbuf, ts.tv_nsec / 1000000);
|
||||
|
||||
vfprintf(fp, fmt, args);
|
||||
fflush(fp);
|
||||
|
Loading…
x
Reference in New Issue
Block a user