]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Remove unnecessary sub-class AccessLogEntry::Private
authorAmos Jeffries <squid3@treenet.co.nz>
Sun, 11 Oct 2015 16:09:26 +0000 (09:09 -0700)
committerAmos Jeffries <squid3@treenet.co.nz>
Sun, 11 Oct 2015 16:09:26 +0000 (09:09 -0700)
Use an accessor to locate the appropriate method string to display in a
consistent way instead.

src/AccessLogEntry.cc
src/AccessLogEntry.h
src/format/Format.cc
src/log/FormatHttpdCombined.cc
src/log/FormatHttpdCommon.cc
src/log/FormatSquidNative.cc
src/log/access_log.cc

index ed9a410f69d76859f6fe36a21b308e9f59595260..7b7f182aa4c24c5d20f781267325a0487a53173a 100644 (file)
@@ -49,6 +49,19 @@ AccessLogEntry::getLogClientIp(char *buf, size_t bufsz) const
     log_ip.toStr(buf, bufsz);
 }
 
+SBuf
+AccessLogEntry::getLogMethod() const
+{
+    SBuf method;
+    if (icp.opcode)
+        method.append(icp_opcode_str[icp.opcode]);
+    else if (htcp.opcode)
+        method.append(htcp.opcode);
+    else
+        method = http.method.image();
+    return method;
+}
+
 AccessLogEntry::~AccessLogEntry()
 {
     safe_free(headers.request);
index b3020746c24cc6b54916fc7e704abd3c77d58dd4..05de64adcbb5be29ef134de839d55d18a65e3d04 100644 (file)
@@ -54,6 +54,9 @@ public:
     /// including indirect forwarded-for IP if configured to log that
     void getLogClientIp(char *buf, size_t bufsz) const;
 
+    /// Fetch the transaction method string (ICP opcode, HTCP opcode or HTTP method)
+    SBuf getLogMethod() const;
+
     const char *url;
 
     /// TCP/IP level details about the client connection
@@ -203,17 +206,6 @@ public:
     } adapt;
 #endif
 
-    // Why is this a sub-class and not a set of real "private:" fields?
-    // TODO: shuffle this to the relevant ICP/HTCP protocol section
-    class Private
-    {
-
-    public:
-        Private() : method_str(NULL) {}
-
-        const char *method_str;
-    } _private;
-
     const char *lastAclName; ///< string for external_acl_type %ACL format code
     const char *lastAclData; ///< string for external_acl_type %DATA format code
 
index 8917feb5bd1759b4eb22cf72002ac3dba2b6e0ae..1bf619dfe71d44880259063d973b8808a43f1fa1 100644 (file)
@@ -1020,10 +1020,8 @@ Format::Format::assemble(MemBuf &mb, const AccessLogEntry::Pointer &al, int logS
             break;
 
         case LFT_REQUEST_METHOD:
-            if (al->_private.method_str) // ICP, HTCP method code
-                out = al->_private.method_str;
-            else {
-                const SBuf &s = al->http.method.image();
+            {
+                const SBuf s(al->getLogMethod());
                 sb.append(s.rawContent(), s.length());
                 out = sb.termedBuf();
                 quote = 1;
index c700eb295033df2afc46ebf83fa578de7632955c..266e20b4c11e42446f768405a465878ea9ab7eb1 100644 (file)
@@ -45,11 +45,7 @@ Log::Format::HttpdCombined(const AccessLogEntry::Pointer &al, Logfile * logfile)
     char clientip[MAX_IPSTRLEN];
     al->getLogClientIp(clientip, MAX_IPSTRLEN);
 
-    static SBuf method;
-    if (al->_private.method_str)
-        method.assign(al->_private.method_str);
-    else
-        method = al->http.method.image();
+    const SBuf method(al->getLogMethod());
 
     logfilePrintf(logfile, "%s %s %s [%s] \"" SQUIDSBUFPH " %s %s/%d.%d\" %d %" PRId64 " \"%s\" \"%s\" %s:%s%s",
                   clientip,
index 3421d03b1e171f9db95bbd498e0e102d7e35dd93..d4f9f16bbfc67a4490bb7f3827ae61405d96c225 100644 (file)
@@ -32,11 +32,7 @@ Log::Format::HttpdCommon(const AccessLogEntry::Pointer &al, Logfile * logfile)
     char clientip[MAX_IPSTRLEN];
     al->getLogClientIp(clientip, MAX_IPSTRLEN);
 
-    static SBuf method;
-    if (al->_private.method_str)
-        method.assign(al->_private.method_str);
-    else
-        method = al->http.method.image();
+    const SBuf method(al->getLogMethod());
 
     logfilePrintf(logfile, "%s %s %s [%s] \"" SQUIDSBUFPH " %s %s/%d.%d\" %d %" PRId64 " %s:%s%s",
                   clientip,
index 59ccc6edb59a9d6907e3faf915630509284e7bfb..e73d4210a86b7f4f5367e3bdca404665c466abeb 100644 (file)
@@ -48,11 +48,7 @@ Log::Format::SquidNative(const AccessLogEntry::Pointer &al, Logfile * logfile)
     char clientip[MAX_IPSTRLEN];
     al->getLogClientIp(clientip, MAX_IPSTRLEN);
 
-    static SBuf method;
-    if (al->_private.method_str)
-        method.assign(al->_private.method_str);
-    else
-        method = al->http.method.image();
+    const SBuf method(al->getLogMethod());
 
     logfilePrintf(logfile, "%9ld.%03d %6ld %s %s/%03d %" PRId64 " " SQUIDSBUFPH " %s %s %s%s/%s %s%s",
                   (long int) current_time.tv_sec,
index 9cdc2506fdd93305e618b2f4a5c95b5eb2f3c735..1eb6339f25414ee75bdd75d62992d1ade317cf6f 100644 (file)
@@ -82,13 +82,6 @@ accessLogLogTo(CustomLog* log, AccessLogEntry::Pointer &al, ACLChecklist * check
     if (!al->http.content_type || *al->http.content_type == '\0')
         al->http.content_type = dash_str;
 
-    if (al->icp.opcode)
-        al->_private.method_str = icp_opcode_str[al->icp.opcode];
-    else if (al->htcp.opcode)
-        al->_private.method_str = al->htcp.opcode;
-    else
-        al->_private.method_str = NULL;
-
     if (al->hier.host[0] == '\0')
         xstrncpy(al->hier.host, dash_str, SQUIDHOSTNAMELEN);