]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Author: Alter <alter@alter.org.ua>
authorAmos Jeffries <amosjeffries@squid-cache.org>
Fri, 27 Jun 2008 13:40:12 +0000 (07:40 -0600)
committerAmos Jeffries <amosjeffries@squid-cache.org>
Fri, 27 Jun 2008 13:40:12 +0000 (07:40 -0600)
Bug 2301: Regression: Log format request/reply size options

MFC: 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 '<st', squid will log total request size
instead of reply size to access.log. For example

logformat altsquid %ts.%03tu %6tr %>a %Ss/%03Hs %st %rm %ru %un %Sh/%<A %mt
access_log /usr/local/squid/logs/access.log altsquid

src/AccessLogEntry.h
src/access_log.cc
src/cf.data.pre
src/client_side.cc
src/icp_v2.cc

index bb4408294e085d16445c379862ce7dfcc0e5ce51..aac6ba70b1bd1d0a9b996d265dade569c7f1fa34 100644 (file)
@@ -79,7 +79,9 @@ public:
     {
 
     public:
-        CacheDetails() : size(0),
+        CacheDetails() :
+                requestSize(0),
+                replySize(0),
                 highOffset(0),
                 objectSize(0),
                 code (LOG_TAG_NONE),
@@ -95,7 +97,8 @@ public:
         }
 
         struct IN_ADDR caddr;
-        int64_t size;
+        int64_t requestSize;
+        int64_t replySize;
         int64_t highOffset;
         int64_t objectSize;
         log_type code;
index fe1428e7f9793f38f1181857217497418290d3cc..5ac1197615694f53c27fbe5d2b810ae938aa3d74 100644 (file)
@@ -368,7 +368,7 @@ typedef enum {
     /*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, */
@@ -383,6 +383,7 @@ typedef enum {
     /*LFT_REPLY_SIZE_BODY_NO_TE, */
 
     LFT_TAG,
+    LFT_IO_SIZE_TOTAL,
     LFT_EXT_LOG,
 
     LFT_PERCENT                        /* special string cases for escaped chars */
@@ -488,7 +489,7 @@ struct logformat_token_table_entry logformat_token_table[] =
         {">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 }, */
@@ -503,6 +504,7 @@ struct logformat_token_table_entry logformat_token_table[] =
         /*{ "<sB", LFT_REPLY_SIZE_BODY_NO_TE }, */
 
         {"et", LFT_TAG},
+        {"st", LFT_IO_SIZE_TOTAL},
         {"ea", LFT_EXT_LOG},
 
         {"%", LFT_PERCENT},
@@ -777,22 +779,22 @@ accessLogCustom(AccessLogEntry * al, customlog * log)
 
         case LFT_REQUEST_VERSION:
             snprintf(tmp, sizeof(tmp), "%d.%d", (int) al->http.version.major, (int) al->http.version.minor);
-
             out = tmp;
+            break;
 
+        case LFT_REQUEST_SIZE_TOTAL:
+            outint = al->cache.requestSize;
+            dooff = 1;
             break;
 
-            /*case LFT_REQUEST_SIZE_TOTAL: */
             /*case LFT_REQUEST_SIZE_LINE: */
             /*case LFT_REQUEST_SIZE_HEADERS: */
             /*case LFT_REQUEST_SIZE_BODY: */
             /*case LFT_REQUEST_SIZE_BODY_NO_TE: */
 
         case LFT_REPLY_SIZE_TOTAL:
-            outoff = al->cache.size;
-
+            outoff = al->cache.replySize;
             dooff = 1;
-
             break;
 
         case LFT_REPLY_HIGHOFFSET:
@@ -822,6 +824,11 @@ accessLogCustom(AccessLogEntry * al, customlog * log)
 
             break;
 
+        case LFT_IO_SIZE_TOTAL:
+            outint = al->cache.requestSize + al->cache.replySize;
+            doint = 1;
+            break;
+
         case LFT_EXT_LOG:
             if (al->request)
                 out = al->request->extacl_log.buf();
@@ -1303,7 +1310,7 @@ accessLogSquid(AccessLogEntry * al, Logfile * logfile)
                       client,
                       log_tags[al->cache.code],
                       al->http.code,
-                      al->cache.size,
+                      al->cache.replySize,
                       al->_private.method_str,
                       al->url,
                       user ? user : dash_str,
@@ -1321,7 +1328,7 @@ accessLogSquid(AccessLogEntry * al, Logfile * logfile)
                       client,
                       log_tags[al->cache.code],
                       al->http.code,
-                      al->cache.size,
+                      al->cache.replySize,
                       al->_private.method_str,
                       al->url,
                       user ? user : dash_str,
@@ -1362,7 +1369,7 @@ accessLogCommon(AccessLogEntry * al, Logfile * logfile)
                   al->url,
                   al->http.version.major, al->http.version.minor,
                   al->http.code,
-                  al->cache.size,
+                  al->cache.replySize,
                   log_tags[al->cache.code],
                   hier_strings[al->hier.code]);
 
index 6502ccf72e3623936f01e51d1878f15130731823..dc5d262b3c21291c5e5f62a9aed393f34139c3ab 100644 (file)
@@ -2008,6 +2008,8 @@ DOC_START
                et      Tag returned by external acl
                ea      Log string returned by external acl
                <st     Reply size including HTTP headers
+               >st     Request size including HTTP headers
+               st      Request+Reply size including HTTP headers
                <sH     Reply high offset sent
                <sS     Upstream object size
                %       a literal % character
index cdf7a2b3018054ff114b814721caec8d8b8f74ab..aa553a951f242ecc3f83abde24c3d4e18246d150 100644 (file)
@@ -459,7 +459,7 @@ clientPrepareLogWithRequestDetails(HttpRequest * request, AccessLogEntry * aLogE
     aLogEntry->http.method = request->method;
     aLogEntry->http.version = request->http_ver;
     aLogEntry->hier = request->hier;
-
+    aLogEntry->cache.requestSize += request->content_length;
     aLogEntry->cache.extuser = request->extacl_user.buf();
 
     if (request->auth_user_request) {
@@ -495,7 +495,9 @@ ClientHttpRequest::logRequest()
 
         al.cache.caddr = getConn() != NULL ? getConn()->log_addr : no_addr;
 
-        al.cache.size = out.size;
+        al.cache.requestSize = req_sz;
+
+        al.cache.replySize = out.size;
 
         al.cache.highOffset = out.offset;
 
index 9ee1c1a9dff4ccc150bdf68431ad6d987ba46d69..4ebc42f181f25ea6b4afd2ca736d2442051cf29a 100644 (file)
@@ -179,7 +179,7 @@ icpLogIcp(struct IN_ADDR caddr, log_type logcode, int len, const char *url, int
 
     al.cache.caddr = caddr;
 
-    al.cache.size = len;
+    al.cache.replySize = len;
 
     al.cache.code = logcode;