#include <string.h>
#include <sys/epoll.h>
#include <sys/timerfd.h>
+#include <time.h>
#include <unistd.h>
#include "logging.h"
unsigned int connections;
};
+static char __timespec[20];
+
+static const char* format_timespec(const struct timespec* t) {
+ // Convert to local time
+ struct tm* tm = localtime(&t->tv_sec);
+
+ size_t s = strftime(__timespec, sizeof(__timespec), "%F %T", tm);
+
+ if (s)
+ return __timespec;
+
+ return NULL;
+}
+
static int dump_stats(struct fireperf_config* conf, const struct fireperf_server_stats* stats) {
- DEBUG(conf, "Printing statistics...\n");
+ struct timespec now;
+
+ // Fetch the time
+ int r = clock_gettime(CLOCK_REALTIME, &now);
+ if (r) {
+ ERROR(conf, "Could not fetch the time: %s\n", strerror(errno));
+ return 1;
+ }
+
+ // Format timestamp
+ const char* timestamp = format_timespec(&now);
+
+ INFO(conf, "--- %s --------------------\n", timestamp);
+ INFO(conf, " %-20s: %20u\n", "Open Connection(s)", stats->connections);
return 0;
}