--------------------- PatchSet 11211 Date: 2007/01/28 23:53:42 Author: hno Branch: HEAD Tag: (none) Log: Author: Alter logging HTTP-request size I've made patch to Squid 2.5-stable14 (r4), which enables logging of http-request size and/or total request+reply size. Patch extends 'logformat' option of squid.conf. '>st' and 'st' can be used to log request size and total size respectively. If 'st' is used instead of 'a %Ss/%03Hs %st %rm %ru %un %Sh/%1.97 src/cf.data.pre:1.383->1.384 src/client_side.c:1.697->1.698 src/structs.h:1.508->1.509 Index: squid/src/access_log.c =================================================================== RCS file: /cvsroot/squid/squid/src/access_log.c,v retrieving revision 1.96 retrieving revision 1.97 diff -u -r1.96 -r1.97 --- squid/src/access_log.c 21 Jan 2007 12:53:56 -0000 1.96 +++ squid/src/access_log.c 28 Jan 2007 23:53:42 -0000 1.97 @@ -1,6 +1,6 @@ /* - * $Id: access_log.c,v 1.96 2007/01/21 12:53:56 adrian Exp $ + * $Id: access_log.c,v 1.97 2007/01/28 23:53:42 hno Exp $ * * DEBUG: section 46 Access Log * AUTHOR: Duane Wessels @@ -300,7 +300,7 @@ /*LFT_REQUEST_QUERY, * // * this is not needed. see strip_query_terms */ LFT_REQUEST_VERSION, -/*LFT_REQUEST_SIZE_TOTAL, */ + LFT_REQUEST_SIZE_TOTAL, /*LFT_REQUEST_SIZE_LINE, */ /*LFT_REQUEST_SIZE_HEADERS, */ /*LFT_REQUEST_SIZE_BODY, */ @@ -312,6 +312,8 @@ /*LFT_REPLY_SIZE_BODY, */ /*LFT_REPLY_SIZE_BODY_NO_TE, */ + LFT_IO_SIZE_TOTAL, + LFT_EXT_LOG, LFT_PERCENT /* special string cases for escaped chars */ @@ -402,20 +404,22 @@ {">v", LFT_REQUEST_VERSION}, {"rv", LFT_REQUEST_VERSION}, -/*{ ">st", LFT_REQUEST_SIZE_TOTAL }, */ + {">st", LFT_REQUEST_SIZE_TOTAL}, /*{ ">sl", LFT_REQUEST_SIZE_LINE }, * / / * the request line "GET ... " */ /*{ ">sh", LFT_REQUEST_SIZE_HEADERS }, */ /*{ ">sb", LFT_REQUEST_SIZE_BODY }, */ /*{ ">sB", LFT_REQUEST_SIZE_BODY_NO_TE }, */ - {"ea", LFT_EXT_LOG}, - {"cache.rq_size; + doint = 1; + break; /*case LFT_REQUEST_SIZE_LINE: */ /*case LFT_REQUEST_SIZE_HEADERS: */ /*case LFT_REQUEST_SIZE_BODY: */ @@ -649,6 +656,11 @@ /*case LFT_REPLY_SIZE_BODY: */ /*case LFT_REPLY_SIZE_BODY_NO_TE: */ + case LFT_IO_SIZE_TOTAL: + outint = al->cache.size + al->cache.rq_size; + doint = 1; + break; + case LFT_EXT_LOG: if (al->request) out = strBuf(al->request->extacl_log); Index: squid/src/cf.data.pre =================================================================== RCS file: /cvsroot/squid/squid/src/cf.data.pre,v retrieving revision 1.383 retrieving revision 1.384 diff -u -r1.383 -r1.384 --- squid/src/cf.data.pre 21 Jan 2007 12:53:57 -0000 1.383 +++ squid/src/cf.data.pre 28 Jan 2007 23:53:42 -0000 1.384 @@ -1,6 +1,6 @@ # -# $Id: cf.data.pre,v 1.383 2007/01/21 12:53:57 adrian Exp $ +# $Id: cf.data.pre,v 1.384 2007/01/28 23:53:42 hno Exp $ # # # SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -1273,6 +1273,8 @@ rv Request protocol version ea Log string returned by external acl st Request size including HTTP headers + st Request+Reply size including HTTP headers % a literal % character logformat squid %ts.%03tu %6tr %>a %Ss/%03Hs %al.cache.size = http->out.size; http->al.cache.code = http->log_type; http->al.cache.msec = tvSubMsec(http->start, current_time); + http->al.cache.rq_size = http->req_sz; if (request) { + http->al.cache.rq_size += request->content_length; if (Config.onoff.log_mime_hdrs) { Packer p; MemBuf mb; Index: squid/src/structs.h =================================================================== RCS file: /cvsroot/squid/squid/src/structs.h,v retrieving revision 1.508 retrieving revision 1.509 diff -u -r1.508 -r1.509 --- squid/src/structs.h 21 Jan 2007 12:54:00 -0000 1.508 +++ squid/src/structs.h 28 Jan 2007 23:53:42 -0000 1.509 @@ -1,6 +1,6 @@ /* - * $Id: structs.h,v 1.508 2007/01/21 12:54:00 adrian Exp $ + * $Id: structs.h,v 1.509 2007/01/28 23:53:42 hno Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -1166,6 +1166,7 @@ struct { struct in_addr caddr; squid_off_t size; + size_t rq_size; log_type code; int msec; const char *rfc931;