From: Willy Tarreau Date: Thu, 20 Dec 2012 14:38:04 +0000 (+0100) Subject: MINOR: log: add a tag for amount of bytes uploaded from client to server X-Git-Tag: v1.5-dev16~22 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c5259fdc57821877164a2d240ff884368b8bb972;p=thirdparty%2Fhaproxy.git MINOR: log: add a tag for amount of bytes uploaded from client to server For POST, PUT, CONNECT or tunnelled connections, it's annoying not to have the amount of uploaded bytes in the logs. %U now reports this value. --- diff --git a/doc/configuration.txt b/doc/configuration.txt index 596ca4736d..d70c9d8f30 100644 --- a/doc/configuration.txt +++ b/doc/configuration.txt @@ -10272,6 +10272,7 @@ Please refer to the table below for currently defined variables : | | %Ts | timestamp | numeric | | | %Tt | Tt | numeric | | | %Tw | Tw | numeric | + | | %U | bytes_uploaded (from client to server) | numeric | | | %ac | actconn | numeric | | | %b | backend_name | string | | | %bc | beconn | numeric | diff --git a/include/types/log.h b/include/types/log.h index ce0c717911..c81ab0de79 100644 --- a/include/types/log.h +++ b/include/types/log.h @@ -65,6 +65,7 @@ enum { LOG_FMT_BACKEND, LOG_FMT_SERVER, LOG_FMT_BYTES, + LOG_FMT_BYTES_UP, LOG_FMT_T, LOG_FMT_TQ, LOG_FMT_TW, diff --git a/src/log.c b/src/log.c index 24273a5509..7483842c48 100644 --- a/src/log.c +++ b/src/log.c @@ -87,7 +87,8 @@ static const struct logformat_type logformat_keywords[] = { { "ft", LOG_FMT_FRONTEND_XPRT, PR_MODE_TCP, LW_INIT, NULL }, /* frontend with transport mode */ { "b", LOG_FMT_BACKEND, PR_MODE_TCP, LW_INIT, NULL }, /* backend */ { "s", LOG_FMT_SERVER, PR_MODE_TCP, LW_SVID, NULL }, /* server */ - { "B", LOG_FMT_BYTES, PR_MODE_TCP, LW_BYTES, NULL }, /* bytes read */ + { "B", LOG_FMT_BYTES, PR_MODE_TCP, LW_BYTES, NULL }, /* bytes from server to client */ + { "U", LOG_FMT_BYTES_UP, PR_MODE_TCP, LW_BYTES, NULL }, /* bytes from client to server */ { "Tq", LOG_FMT_TQ, PR_MODE_HTTP, LW_BYTES, NULL }, /* Tq */ { "Tw", LOG_FMT_TW, PR_MODE_TCP, LW_BYTES, NULL }, /* Tw */ { "Tc", LOG_FMT_TC, PR_MODE_TCP, LW_BYTES, NULL }, /* Tc */ @@ -1117,6 +1118,16 @@ int build_logline(struct session *s, char *dst, size_t maxsize, struct list *lis last_isspace = 0; break; + case LOG_FMT_BYTES_UP: // %U + if (!(tolog & LW_BYTES)) + LOGCHAR('+'); + ret = lltoa(s->logs.bytes_in, tmplog, dst + maxsize - tmplog); + if (ret == NULL) + goto out; + tmplog = ret; + last_isspace = 0; + break; + case LOG_FMT_CCLIENT: // %cc src = txn->cli_cookie; ret = lf_text(tmplog, src, dst + maxsize - tmplog, tmp);