]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: log: use "%ts" to log term status only and "%tsc" to log with cookie
authorWilly Tarreau <w@1wt.eu>
Mon, 12 Mar 2012 14:09:42 +0000 (15:09 +0100)
committerWilly Tarreau <w@1wt.eu>
Mon, 12 Mar 2012 14:50:53 +0000 (15:50 +0100)
The difference could be seen when logging a request in HTTP mode with option
tcplog, as it would keep emitting 4 chars. Better use two distinct flags to
clear the confusion.

doc/configuration.txt
include/types/log.h
src/log.c

index 58ceebbe87f11a07a0542cf2035c3c4d5cf2e625..66ba72c0ff817e269abb91f514cd1077844d30f2 100644 (file)
@@ -8767,12 +8767,12 @@ Flags are :
 At the moment, the default HTTP format is defined this way :
 
     log-format %Ci:%Cp\ [%t]\ %f\ %b/%s\ %Tq/%Tw/%Tc/%Tr/%Tt\ %st\ %B\ %cc\ \
-               %cs\ %ts\ %ac/%fc/%bc/%sc/%rc\ %sq/%bq\ %hr\ %hs\ %{+Q}r
+               %cs\ %tsc\ %ac/%fc/%bc/%sc/%rc\ %sq/%bq\ %hr\ %hs\ %{+Q}r
 
 the default CLF format is defined this way :
 
     log-format %{+Q}o\ %{-Q}Ci\ -\ -\ [%T]\ %r\ %st\ %B\ \"\"\ \"\"\ %Cp\ \
-               %ms\ %f\ %b\ %s\ \%Tq\ %Tw\ %Tc\ %Tr\ %Tt\ %ts\ %ac\ %fc\ \
+               %ms\ %f\ %b\ %s\ \%Tq\ %Tw\ %Tc\ %Tr\ %Tt\ %tsc\ %ac\ %fc\ \
                %bc\ %sc\ %rc\ %sq\ %bq\ %cc\ %cs\ \%hrl\ %hsl
 
 and the default TCP format is defined this way :
@@ -8817,6 +8817,7 @@ Please refer to the table below for currently defined variables :
   |   | %sq  | srv_queue                                     | numeric     |
   | * | %st  | status_code                                   | numeric     |
   |   | %ts  | termination_state                             | string      |
+  | * | %tsc | termination_state with cookie status          | string      |
   +---+------+-----------------------------------------------+-------------+
 
 *: mode httplog only
index 2f11aabb7f88254b58dd537003a29c610c16fc74..741fba935ddce1f4c804fe5862d869460b1c0e34 100644 (file)
@@ -63,6 +63,7 @@ enum {
        LOG_CCLIENT,
        LOG_CSERVER,
        LOG_TERMSTATE,
+       LOG_TERMSTATE_CK,
        LOG_CONN,
        LOG_ACTCONN,
        LOG_FECONN,
index bc36f694a8b3d15ef6707d66c7131ef3bdcbca3e..4ef51e1e9abfa671272d72c59080a788c07237a0 100644 (file)
--- a/src/log.c
+++ b/src/log.c
@@ -85,6 +85,7 @@ static const struct logformat_type logformat_keywords[] = {
        { "cc", LOG_CCLIENT, PR_MODE_HTTP, NULL },  /* client cookie */
        { "cs", LOG_CSERVER, PR_MODE_HTTP, NULL },  /* server cookie */
        { "ts", LOG_TERMSTATE, PR_MODE_TCP, NULL },/* terminaison state */
+       { "tsc", LOG_TERMSTATE_CK, PR_MODE_HTTP, NULL },/* terminaison state with cookie status */
        { "ac", LOG_ACTCONN, PR_MODE_TCP, NULL },  /* actconn */
        { "fc", LOG_FECONN, PR_MODE_TCP, NULL },   /* feconn */
        { "bc", LOG_BECONN, PR_MODE_TCP, NULL },   /* beconn */
@@ -100,8 +101,8 @@ static const struct logformat_type logformat_keywords[] = {
        { 0, 0, 0, NULL }
 };
 
-char default_http_log_format[] = "%Ci:%Cp [%t] %f %b/%s %Tq/%Tw/%Tc/%Tr/%Tt %st %B %cc %cs %ts %ac/%fc/%bc/%sc/%rc %sq/%bq %hr %hs %{+Q}r"; // default format
-char clf_http_log_format[] = "%{+Q}o %{-Q}Ci - - [%T] %r %st %B \"\" \"\" %Cp %ms %f %b %s %Tq %Tw %Tc %Tr %Tt %ts %ac %fc %bc %sc %rc %sq %bq %cc %cs %hrl %hsl";
+char default_http_log_format[] = "%Ci:%Cp [%t] %f %b/%s %Tq/%Tw/%Tc/%Tr/%Tt %st %B %cc %cs %tsc %ac/%fc/%bc/%sc/%rc %sq/%bq %hr %hs %{+Q}r"; // default format
+char clf_http_log_format[] = "%{+Q}o %{-Q}Ci - - [%T] %r %st %B \"\" \"\" %Cp %ms %f %b %s %Tq %Tw %Tc %Tr %Tt %tsc %ac %fc %bc %sc %rc %sq %bq %cc %cs %hrl %hsl";
 char default_tcp_log_format[] = "%Ci:%Cp [%t] %f %b/%s %Tw/%Tc/%Tt %B %ts %ac/%fc/%bc/%sc/%rc %sq/%bq";
 char *log_format = NULL;
 
@@ -936,13 +937,17 @@ void sess_log(struct session *s)
                                break;
 
                        case LOG_TERMSTATE: // %ts
+                               LOGCHAR(sess_term_cond[(s->flags & SN_ERR_MASK) >> SN_ERR_SHIFT]);
+                               LOGCHAR(sess_fin_state[(s->flags & SN_FINST_MASK) >> SN_FINST_SHIFT]);
+                               *tmplog = '\0';
+                               last_isspace = 0;
+                               break;
 
+                       case LOG_TERMSTATE_CK: // %tsc, same as TS with cookie state (for mode HTTP)
                                LOGCHAR(sess_term_cond[(s->flags & SN_ERR_MASK) >> SN_ERR_SHIFT]);
                                LOGCHAR(sess_fin_state[(s->flags & SN_FINST_MASK) >> SN_FINST_SHIFT]);
-                               if (fe->mode == PR_MODE_HTTP) {
-                                       LOGCHAR((be->options & PR_O_COOK_ANY) ? sess_cookie[(txn->flags & TX_CK_MASK) >> TX_CK_SHIFT] : '-');
-                                       LOGCHAR((be->options & PR_O_COOK_ANY) ? sess_set_cookie[(txn->flags & TX_SCK_MASK) >> TX_SCK_SHIFT] : '-');
-                               }
+                               LOGCHAR((be->options & PR_O_COOK_ANY) ? sess_cookie[(txn->flags & TX_CK_MASK) >> TX_CK_SHIFT] : '-');
+                               LOGCHAR((be->options & PR_O_COOK_ANY) ? sess_set_cookie[(txn->flags & TX_SCK_MASK) >> TX_SCK_SHIFT] : '-');
                                *tmplog = '\0';
                                last_isspace = 0;
                                break;