aboutsummaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorarf20 <aruizfernandez05@gmail.com>2025-10-20 23:18:26 +0200
committerarf20 <aruizfernandez05@gmail.com>2025-10-20 23:18:26 +0200
commit287b4af722b7ec089645cf9cd75233c6c90908cf (patch)
treee70d1ad7a1f67cb79b26b66e33bce621b852a8de /main.c
parent43be0d7be77ee5829058c5704a76db0765fe19c8 (diff)
downloadarfnet2-status-287b4af722b7ec089645cf9cd75233c6c90908cf.tar.gz
arfnet2-status-287b4af722b7ec089645cf9cd75233c6c90908cf.zip
HTTP monitoring
Diffstat (limited to 'main.c')
-rw-r--r--main.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/main.c b/main.c
index f01d928..15379b3 100644
--- a/main.c
+++ b/main.c
@@ -1,16 +1,18 @@
#include <sys/types.h>
#include <sys/select.h>
#include <sys/socket.h>
-
#include <netinet/in.h>
#include <arpa/inet.h>
-#include <microhttpd.h>
-
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
+#include <time.h>
+
+#include <microhttpd.h>
+
+
#include "monitor.h"
@@ -35,7 +37,13 @@ enum MHD_Result answer_to_connection(
(const struct sockaddr_in**)MHD_get_connection_info(
connection, MHD_CONNECTION_INFO_CLIENT_ADDRESS);
- printf("%s - %s %s: ", inet_ntoa((*coninfo)->sin_addr), method, url);
+ time_t time_now = time(NULL);
+ struct tm *tm_now = gmtime(&time_now);
+ static char timestr[256];
+ strftime(timestr, 256, "%Y-%m-%d %H-%M-%S", tm_now);
+
+ printf("[%s] [webserver] %s %s %s: ",
+ timestr, inet_ntoa((*coninfo)->sin_addr), method, url);
struct MHD_Response *response;
int ret;