MINOR: log: add the %Td log-format specifier
As suggested by Pavlos, it's too bad that we didn't have a %Td log
format tag given that there are a few mentions of Td corresponding
to the data transmission time already in the doc, so this is now done.
Just like the other specifiers, we report -1 if the connection failed
before reaching the data transmission state.
diff --git a/doc/configuration.txt b/doc/configuration.txt
index 80b9c01..1099695 100644
--- a/doc/configuration.txt
+++ b/doc/configuration.txt
@@ -14699,6 +14699,7 @@
| | %ST | status_code | numeric |
| | %T | gmt_date_time | date |
| | %Tc | Tc | numeric |
+ | | %Td | Td = Tt - (Tq + Tw + Tc + Tr) | numeric |
| | %Tl | local_date_time | date |
| H | %Tq | Tq | numeric |
| H | %Tr | Tr | numeric |
diff --git a/include/types/log.h b/include/types/log.h
index e974086..25d872e 100644
--- a/include/types/log.h
+++ b/include/types/log.h
@@ -81,6 +81,7 @@
LOG_FMT_TW,
LOG_FMT_TC,
LOG_FMT_TR,
+ LOG_FMT_TD,
LOG_FMT_TT,
LOG_FMT_STATUS,
LOG_FMT_CCLIENT,
diff --git a/src/log.c b/src/log.c
index 2d02247..99c89f3 100644
--- a/src/log.c
+++ b/src/log.c
@@ -127,6 +127,7 @@
{ "Tl", LOG_FMT_DATELOCAL, PR_MODE_TCP, LW_INIT, NULL }, /* date local timezone */
{ "Tq", LOG_FMT_TQ, PR_MODE_HTTP, LW_BYTES, NULL }, /* Tq */
{ "Tr", LOG_FMT_TR, PR_MODE_HTTP, LW_BYTES, NULL }, /* Tr */
+ { "Td", LOG_FMT_TD, PR_MODE_TCP, LW_BYTES, NULL }, /* Td = Tt - (Tq + Tw + Tc + Tr) */
{ "Ts", LOG_FMT_TS, PR_MODE_TCP, LW_INIT, NULL }, /* timestamp GMT */
{ "Tt", LOG_FMT_TT, PR_MODE_TCP, LW_BYTES, NULL }, /* Tt */
{ "Tw", LOG_FMT_TW, PR_MODE_TCP, LW_BYTES, NULL }, /* Tw */
@@ -1655,6 +1656,19 @@
last_isspace = 0;
break;
+ case LOG_FMT_TD: // %Td
+ if (s->be->mode == PR_MODE_HTTP)
+ ret = ltoa_o((s->logs.t_data >= 0) ? s->logs.t_close - s->logs.t_data : -1,
+ tmplog, dst + maxsize - tmplog);
+ else
+ ret = ltoa_o((s->logs.t_connect >= 0) ? s->logs.t_close - s->logs.t_connect : -1,
+ tmplog, dst + maxsize - tmplog);
+ if (ret == NULL)
+ goto out;
+ tmplog = ret;
+ last_isspace = 0;
+ break;
+
case LOG_FMT_TT: // %Tt
if (!(fe->to_log & LW_BYTES))
LOGCHAR('+');