From: Amos Jeffries Date: Sun, 11 Oct 2015 16:09:26 +0000 (-0700) Subject: Remove unnecessary sub-class AccessLogEntry::Private X-Git-Tag: SQUID_4_0_1~4 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=58b148e1ab40fbd47428daa3836fad049dc88dcc;p=thirdparty%2Fsquid.git Remove unnecessary sub-class AccessLogEntry::Private Use an accessor to locate the appropriate method string to display in a consistent way instead. --- diff --git a/src/AccessLogEntry.cc b/src/AccessLogEntry.cc index ed9a410f69..7b7f182aa4 100644 --- a/src/AccessLogEntry.cc +++ b/src/AccessLogEntry.cc @@ -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); diff --git a/src/AccessLogEntry.h b/src/AccessLogEntry.h index b3020746c2..05de64adcb 100644 --- a/src/AccessLogEntry.h +++ b/src/AccessLogEntry.h @@ -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 diff --git a/src/format/Format.cc b/src/format/Format.cc index 8917feb5bd..1bf619dfe7 100644 --- a/src/format/Format.cc +++ b/src/format/Format.cc @@ -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; diff --git a/src/log/FormatHttpdCombined.cc b/src/log/FormatHttpdCombined.cc index c700eb2950..266e20b4c1 100644 --- a/src/log/FormatHttpdCombined.cc +++ b/src/log/FormatHttpdCombined.cc @@ -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, diff --git a/src/log/FormatHttpdCommon.cc b/src/log/FormatHttpdCommon.cc index 3421d03b1e..d4f9f16bbf 100644 --- a/src/log/FormatHttpdCommon.cc +++ b/src/log/FormatHttpdCommon.cc @@ -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, diff --git a/src/log/FormatSquidNative.cc b/src/log/FormatSquidNative.cc index 59ccc6edb5..e73d4210a8 100644 --- a/src/log/FormatSquidNative.cc +++ b/src/log/FormatSquidNative.cc @@ -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, diff --git a/src/log/access_log.cc b/src/log/access_log.cc index 9cdc2506fd..1eb6339f25 100644 --- a/src/log/access_log.cc +++ b/src/log/access_log.cc @@ -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);