From 11b57acd2b149eee826e2e3a1496d4393def8d0a Mon Sep 17 00:00:00 2001 From: benchea dan Date: Wed, 15 Jun 2022 14:57:09 +0300 Subject: [PATCH 1/6] Update pdns-logger-file.c adding timestamp --- src/pdns-logger-file.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/pdns-logger-file.c b/src/pdns-logger-file.c index 61ba5b2..4dbf4e9 100644 --- a/src/pdns-logger-file.c +++ b/src/pdns-logger-file.c @@ -133,7 +133,19 @@ static pdns_status_t logfile_log(void *rawpb) { } sz = sizeof(str) - 1; - + + //adding timestampt to file log + //format : [ 15 6 2022 14:55:58 ] + time_t rawtime; + struct tm * timeinfo; + time(&rawtime); + timeinfo = localtime(&rawtime); + pc=snprintf (tmp, sizeof(tmp), "[ %d %d %d %d:%d:%d ]", timeinfo->tm_mday, + timeinfo->tm_mon + 1, timeinfo->tm_year + 1900, + timeinfo->tm_hour, timeinfo->tm_min, timeinfo->tm_sec); + strncat(str, tmp, sz); + sz -= pc; + if (msg->has_id) { pc = snprintf(tmp, sizeof(tmp), "QID: %d ", msg->id); strncat(str, tmp, sz); From 9d5f0d1bff8ab2128497359318ec1e6637f2e072 Mon Sep 17 00:00:00 2001 From: benchea dan Date: Wed, 15 Jun 2022 14:57:50 +0300 Subject: [PATCH 2/6] Update ini.c adding time.h --- src/inih/ini.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/inih/ini.c b/src/inih/ini.c index 7fe7bda..4ca32c3 100644 --- a/src/inih/ini.c +++ b/src/inih/ini.c @@ -14,6 +14,7 @@ home page for more info: #include #include #include +#include #include "ini.h" From e904ba44078bfd036d4f378f44fb6314d1f8d537 Mon Sep 17 00:00:00 2001 From: benchea dan Date: Mon, 4 Jul 2022 14:50:41 +0300 Subject: [PATCH 3/6] remove time.h --- src/inih/ini.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/inih/ini.c b/src/inih/ini.c index 4ca32c3..7fe7bda 100644 --- a/src/inih/ini.c +++ b/src/inih/ini.c @@ -14,7 +14,6 @@ home page for more info: #include #include #include -#include #include "ini.h" From c80ddd8f5fa1b623e73c2a503a9fc6b11e139743 Mon Sep 17 00:00:00 2001 From: benchea dan Date: Mon, 4 Jul 2022 14:51:14 +0300 Subject: [PATCH 4/6] add time.h --- src/inih/ini.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/inih/ini.h b/src/inih/ini.h index dc150d1..93d4af7 100644 --- a/src/inih/ini.h +++ b/src/inih/ini.h @@ -16,7 +16,8 @@ extern "C" { #endif #include - +#include + /* Nonzero if ini_handler callback should accept lineno parameter. */ #ifndef INI_HANDLER_LINENO #define INI_HANDLER_LINENO 1 From 60bee62f17f315abc337f9136943941040aef8c9 Mon Sep 17 00:00:00 2001 From: benchea dan Date: Mon, 4 Jul 2022 15:34:02 +0300 Subject: [PATCH 5/6] change log format --- src/pdns-logger-file.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/pdns-logger-file.c b/src/pdns-logger-file.c index 4dbf4e9..c0395be 100644 --- a/src/pdns-logger-file.c +++ b/src/pdns-logger-file.c @@ -135,14 +135,25 @@ static pdns_status_t logfile_log(void *rawpb) { sz = sizeof(str) - 1; //adding timestampt to file log - //format : [ 15 6 2022 14:55:58 ] + //format : Jan 01 2022 log... + char mounthString[4]; + const char * months[12] = {"Jan", "Feb", "Mar", "Apr", "May", "June", "July", "Aug", "Sep", "Oct", "Nov", "Dec"}; time_t rawtime; struct tm * timeinfo; + time(&rawtime); timeinfo = localtime(&rawtime); - pc=snprintf (tmp, sizeof(tmp), "[ %d %d %d %d:%d:%d ]", timeinfo->tm_mday, - timeinfo->tm_mon + 1, timeinfo->tm_year + 1900, + + //convert int to string mounth + if (timeinfo->tm_mon >= 0 && timeinfo->tm_mon < 12 ){ + snprintf(mounthString, 4, months[timeinfo->tm_mon]); + }else{ + snprintf(mounthString, 4, "N/A "); + } + pc=snprintf (tmp, sizeof(tmp), " %s %d %d %d:%d:%d ", mounthString, + timeinfo->tm_mday , timeinfo->tm_year + 1900, timeinfo->tm_hour, timeinfo->tm_min, timeinfo->tm_sec); + strncat(str, tmp, sz); sz -= pc; From a41d6cb5c2f0f10262f4a9653581b8e5b8a33bca Mon Sep 17 00:00:00 2001 From: benchea dan Date: Mon, 4 Jul 2022 15:43:08 +0300 Subject: [PATCH 6/6] increase size from 1024 to 4096 --- src/pdns-logger-file.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pdns-logger-file.c b/src/pdns-logger-file.c index c0395be..858e795 100644 --- a/src/pdns-logger-file.c +++ b/src/pdns-logger-file.c @@ -115,8 +115,8 @@ static pdns_status_t logfile_log(void *rawpb) { PBDNSMessage__DNSQuestion *q; PBDNSMessage__DNSResponse *r; int sz, pc; - char str[1024] = ""; - char tmp[1024] = ""; + char str[4096] = ""; + char tmp[4096] = ""; if (disabled) { return PDNS_OK;