commit 1418e6255c9ead6218fb6559b4bf23d31d0a6ce9
parent c46bf03a856acfff146c52fbe1a59eadccbb2127
Author: Jacob R. Edwards <jacob@jacobedwards.org>
Date: Sun, 30 Apr 2023 17:15:34 -0700
Add timestamp to log entries
Diffstat:
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/aps/log.c b/aps/log.c
@@ -24,6 +24,7 @@
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
+#include <time.h>
#include "aps.h"
#include "bug.h"
@@ -66,13 +67,17 @@ levelstr(int level)
void
aps_log(struct aps *aps, int fd, int level, char *subject, char *fmt, ...)
{
- va_list ap;
char *p;
+ char tb[20];
+ time_t now;
+ va_list ap;
if (fmt == NULL || (aps && !(level & aps->loglevel)))
return;
- fprintf(stderr, "aps: ");
+ now = time(NULL);
+ strftime(tb, sizeof(tb), "%F %T", localtime(&now));
+ fprintf(stderr, "aps at %s ", tb);
if (fd)
fprintf(stderr, "client %d ", fd);