mirror of
https://github.com/jorisvink/kore
synced 2025-03-09 04:29:02 -04:00
Add timestamp prefix to log when not using syslog.
This commit is contained in:
parent
77848e0708
commit
450aabbea1
10
src/log.c
10
src/log.c
@ -16,6 +16,7 @@
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <time.h>
|
||||
#include <syslog.h>
|
||||
|
||||
#include "kore.h"
|
||||
@ -129,7 +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];
|
||||
|
||||
va_start(args, fmt);
|
||||
|
||||
@ -142,6 +146,12 @@ log_print(int prio, const char *fmt, ...)
|
||||
break;
|
||||
}
|
||||
|
||||
time(&now);
|
||||
t = localtime(&now);
|
||||
|
||||
if (strftime(tbuf, sizeof(tbuf), "%y-%m-%d %H:%S:%M", t) > 0)
|
||||
fprintf(fp, "%s ", tbuf);
|
||||
|
||||
vfprintf(fp, fmt, args);
|
||||
fflush(fp);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user