#include "HierarchyLogEntry.h"
#include "icp_opcode.h"
#include "ip/Address.h"
-#include "HttpRequestMethod.h"
+#include "LogTags.h"
+#include "Notes.h"
#if ICAP_CLIENT
#include "adaptation/icap/Elements.h"
#endif
-#include "Notes.h"
#if USE_SSL
#include "ssl/gadgets.h"
#endif
int replyHeadersSize; ///< sent, including status line
int64_t highOffset;
int64_t objectSize;
- log_type code;
+ LogTags code;
int msec;
const char *rfc931;
const char *authuser;
#include "ip/Address.h"
#include "hash.h"
+#include "LogTags.h"
#include "enums.h"
#include "typedefs.h"
#include "cbdata.h"
#include "icp_opcode.h"
#include "ip/Address.h"
#include "StoreClient.h"
+#include "LogTags.h"
class HttpRequest;
struct timeval start;
#endif
- log_type logcode;
+ LogTags logcode;
struct timeval queue_time;
};
icp_opcode icpGetCommonOpcode();
/// \ingroup ServerProtocolICPAPI
-int icpUdpSend(int, const Ip::Address &, icp_common_t *, log_type, int);
+int icpUdpSend(int, const Ip::Address &, icp_common_t *, LogTags, int);
/// \ingroup ServerProtocolICPAPI
-log_type icpLogFromICPCode(icp_opcode opcode);
+LogTags icpLogFromICPCode(icp_opcode opcode);
/// \ingroup ServerProtocolICPAPI
void icpDenyAccess(Ip::Address &from, char *url, int reqnum, int fd);
--- /dev/null
+#ifndef SQUID_SRC_LOGTAGS_H
+#define SQUID_SRC_LOGTAGS_H
+
+/** Squid transaction result code/tag set.
+ *
+ * These codes indicate how the request was received
+ * and some details about its processing pathway.
+ *
+ * see also http://wiki.squid-cache.org/SquidFaq/SquidLogs#Squid_result_codes
+ * for details on particular components.
+ */
+typedef enum {
+ LOG_TAG_NONE = 0,
+ LOG_TCP_HIT,
+ LOG_TCP_MISS,
+ LOG_TCP_REFRESH_UNMODIFIED, // refresh from origin revalidated existing entry
+ LOG_TCP_REFRESH_FAIL_OLD, // refresh from origin failed, stale reply sent
+ LOG_TCP_REFRESH_FAIL_ERR, // refresh from origin failed, error forwarded
+ LOG_TCP_REFRESH_MODIFIED, // refresh from origin replaced existing entry
+ LOG_TCP_CLIENT_REFRESH_MISS,
+ LOG_TCP_IMS_HIT,
+ LOG_TCP_SWAPFAIL_MISS,
+ LOG_TCP_NEGATIVE_HIT,
+ LOG_TCP_MEM_HIT,
+ LOG_TCP_DENIED,
+ LOG_TCP_DENIED_REPLY,
+ LOG_TCP_OFFLINE_HIT,
+ LOG_TCP_REDIRECT,
+ LOG_UDP_HIT,
+ LOG_UDP_MISS,
+ LOG_UDP_DENIED,
+ LOG_UDP_INVALID,
+ LOG_UDP_MISS_NOFETCH,
+ LOG_ICP_QUERY,
+ LOG_TYPE_MAX
+} LogTags;
+
+/// list of string representations for LogTags
+extern const char *LogTags_str[];
+
+/// determine if the log tag code indicates a cache HIT
+inline bool logTypeIsATcpHit(LogTags code)
+{
+ return
+ (code == LOG_TCP_HIT) ||
+ (code == LOG_TCP_IMS_HIT) ||
+ (code == LOG_TCP_REFRESH_FAIL_OLD) ||
+ (code == LOG_TCP_REFRESH_UNMODIFIED) ||
+ (code == LOG_TCP_NEGATIVE_HIT) ||
+ (code == LOG_TCP_MEM_HIT) ||
+ (code == LOG_TCP_OFFLINE_HIT);
+}
+
+/// iterator for LogTags enumeration
+inline LogTags &operator++ (LogTags &aLogType)
+{
+ int tmp = (int)aLogType;
+ aLogType = (LogTags)(++tmp);
+ return aLogType;
+}
+
+#endif
$(LEAKFINDERSOURCE) \
SquidList.h \
SquidList.cc \
+ LogTags.h \
lookup_t.h \
main.cc \
Mem.h \
globals.cc \
hier_code.cc \
icp_opcode.cc \
+ LogTags.cc \
lookup_t.cc \
repl_modules.cc \
swap_log_op.cc
err_detail_type.cc: err_detail_type.h mk-string-arrays.awk
$(AWK) -f $(srcdir)/mk-string-arrays.awk < $(srcdir)/err_detail_type.h | sed 's/ERR_DETAIL_//' > $@ || ($(RM) -f $@ && exit 1)
+LogTags.cc: LogTags.h mk-string-arrays.awk
+ $(AWK) -f $(srcdir)/mk-string-arrays.awk < $(srcdir)/LogTags.h | sed 's/LOG_//' > $@ || ($(RM) -f $@ && exit 1)
+
lookup_t.cc: lookup_t.h mk-string-arrays.awk
$(AWK) -f $(srcdir)/mk-string-arrays.awk < $(srcdir)/lookup_t.h > $@ || ($(RM) -f $@ && exit 1)
#include "base/RefCount.h"
#include "enums.h"
+#include "LogTags.h"
#include "SquidString.h"
namespace Adaptation
#if USE_SSL
String ssluser; ///< the username from SSL
#endif
- log_type logType; ///< the squid request status (TCP_MISS etc)
+ LogTags logType; ///< the squid request status (TCP_MISS etc)
String log_uri; ///< the request uri
size_t req_sz; ///< the request size
}
#endif
void
-clientdbUpdate(const Ip::Address &addr, log_type ltype, AnyP::ProtocolType p, size_t size)
+clientdbUpdate(const Ip::Address &addr, LogTags ltype, AnyP::ProtocolType p, size_t size)
{
char key[MAX_IPSTRLEN];
ClientInfo *c;
return 1;
}
-log_type &operator++ (log_type &aLogType)
-{
- int tmp = (int)aLogType;
- aLogType = (log_type)(++tmp);
- return aLogType;
-}
-
void
clientdbDump(StoreEntry * sentry)
{
const char *name;
ClientInfo *c;
- log_type l;
int icp_total = 0;
int icp_hits = 0;
int http_total = 0;
storeAppendPrintf(sentry, " ICP Requests %d\n",
c->Icp.n_requests);
- for (l = LOG_TAG_NONE; l < LOG_TYPE_MAX; ++l) {
+ for (LogTags l = LOG_TAG_NONE; l < LOG_TYPE_MAX; ++l) {
if (c->Icp.result_hist[l] == 0)
continue;
if (LOG_UDP_HIT == l)
icp_hits += c->Icp.result_hist[l];
- storeAppendPrintf(sentry, " %-20.20s %7d %3d%%\n",Format::log_tags[l], c->Icp.result_hist[l], Math::intPercent(c->Icp.result_hist[l], c->Icp.n_requests));
+ storeAppendPrintf(sentry, " %-20.20s %7d %3d%%\n",LogTags_str[l], c->Icp.result_hist[l], Math::intPercent(c->Icp.result_hist[l], c->Icp.n_requests));
}
storeAppendPrintf(sentry, " HTTP Requests %d\n", c->Http.n_requests);
- for (l = LOG_TAG_NONE; l < LOG_TYPE_MAX; ++l) {
+ for (LogTags l = LOG_TAG_NONE; l < LOG_TYPE_MAX; ++l) {
if (c->Http.result_hist[l] == 0)
continue;
storeAppendPrintf(sentry,
" %-20.20s %7d %3d%%\n",
- Format::log_tags[l],
+ LogTags_str[l],
c->Http.result_hist[l],
Math::intPercent(c->Http.result_hist[l], c->Http.n_requests));
}
variable_list *Answer = NULL;
int aggr = 0;
- log_type l;
switch (Var->name[LEN_SQ_NET + 2]) {
case MESH_CTBL_HTHITS:
aggr = 0;
- for (l = LOG_TAG_NONE; l < LOG_TYPE_MAX; ++l) {
+ for (LogTags l = LOG_TAG_NONE; l < LOG_TYPE_MAX; ++l) {
if (logTypeIsATcpHit(l))
aggr += c->Http.result_hist[l];
}
#define SQUID_CLIENT_DB_H_
#include "anyp/ProtocolType.h"
-#include "enums.h"
+//#include "enums.h"
#include "ip/Address.h"
+#include "LogTags.h"
+
namespace Ip
{
class Address;
class ClientInfo;
void clientdbInit(void);
-void clientdbUpdate(const Ip::Address &, log_type, AnyP::ProtocolType, size_t);
+void clientdbUpdate(const Ip::Address &, LogTags, AnyP::ProtocolType, size_t);
int clientdbCutoffDenied(const Ip::Address &);
void clientdbDump(StoreEntry *);
void clientdbFreeMemory(void);
static int clientIsContentLengthValid(HttpRequest * r);
static int clientIsRequestBodyTooLargeForPolicy(int64_t bodyLength);
-static void clientUpdateStatHistCounters(log_type logType, int svc_time);
-static void clientUpdateStatCounters(log_type logType);
+static void clientUpdateStatHistCounters(LogTags logType, int svc_time);
+static void clientUpdateStatCounters(LogTags logType);
static void clientUpdateHierCounters(HierarchyLogEntry *);
static bool clientPingHasFinished(ping_data const *aPing);
void prepareLogWithRequestDetails(HttpRequest *, AccessLogEntry::Pointer &);
#endif
static int responseFinishedOrFailed(HttpReply * rep, StoreIOBuffer const &receivedData);
static void ClientSocketContextPushDeferredIfNeeded(ClientSocketContext::Pointer deferredRequest, ConnStateData * conn);
-static void clientUpdateSocketStats(log_type logType, size_t size);
+static void clientUpdateSocketStats(LogTags logType, size_t size);
char *skipLeadingSpace(char *aString);
static void connNoteUseOfBuffer(ConnStateData* conn, size_t byteCount);
#endif
void
-clientUpdateStatCounters(log_type logType)
+clientUpdateStatCounters(LogTags logType)
{
++statCounter.client_http.requests;
}
void
-clientUpdateStatHistCounters(log_type logType, int svc_time)
+clientUpdateStatHistCounters(LogTags logType, int svc_time)
{
statCounter.client_http.allSvcTime.count(svc_time);
/**
}
void
-clientUpdateSocketStats(log_type logType, size_t size)
+clientUpdateSocketStats(LogTags logType, size_t size)
{
if (size == 0)
return;
if (http->storeEntry()) {
if (EBIT_TEST(http->storeEntry()->flags, ENTRY_SPECIAL)) {
debugs(88, DBG_CRITICAL, "clientProcessMiss: miss on a special object (" << url << ").");
- debugs(88, DBG_CRITICAL, "\tlog_type = " << Format::log_tags[http->logType]);
+ debugs(88, DBG_CRITICAL, "\tlog_type = " << LogTags_str[http->logType]);
http->storeEntry()->dump(1);
}
{
PROF_start(httpStart);
logType = LOG_TAG_NONE;
- debugs(85, 4, "ClientHttpRequest::httpStart: " << Format::log_tags[logType] << " for '" << uri << "'");
+ debugs(85, 4, LogTags_str[logType] << " for '" << uri << "'");
/* no one should have touched this */
assert(out.offset == 0);
#include "dlink.h"
#include "base/AsyncJob.h"
#include "HttpHeaderRange.h"
+#include "LogTags.h"
#if USE_ADAPTATION
#include "adaptation/forward.h"
HttpHdrRangeIter range_iter; /* data for iterating thru range specs */
size_t req_sz; /* raw request size on input, not current request size */
- log_type logType;
+
+ /// the processing tags associated with this request transaction.
+ // NP: still an enum so each stage altering it must take care when replacing it.
+ LogTags logType;
struct timeval start_time;
AccessLogEntry::Pointer al; ///< access.log entry
#ifndef SQUID_ENUMS_H
#define SQUID_ENUMS_H
-typedef enum {
- LOG_TAG_NONE,
- LOG_TCP_HIT,
- LOG_TCP_MISS,
- LOG_TCP_REFRESH_UNMODIFIED, // refresh from origin revalidated existing entry
- LOG_TCP_REFRESH_FAIL_OLD, // refresh from origin failed, stale reply sent
- LOG_TCP_REFRESH_FAIL_ERR, // refresh from origin failed, error forwarded
- LOG_TCP_REFRESH_MODIFIED, // refresh from origin replaced existing entry
- LOG_TCP_CLIENT_REFRESH_MISS,
- LOG_TCP_IMS_HIT,
- LOG_TCP_SWAPFAIL_MISS,
- LOG_TCP_NEGATIVE_HIT,
- LOG_TCP_MEM_HIT,
- LOG_TCP_DENIED,
- LOG_TCP_DENIED_REPLY,
- LOG_TCP_OFFLINE_HIT,
- LOG_TCP_REDIRECT,
- LOG_UDP_HIT,
- LOG_UDP_MISS,
- LOG_UDP_DENIED,
- LOG_UDP_INVALID,
- LOG_UDP_MISS_NOFETCH,
- LOG_ICP_QUERY,
- LOG_TYPE_MAX
-} log_type;
-
enum fd_type {
FD_NONE,
FD_LOG,
LOG_QUOTE_RAW
};
-extern const char *log_tags[];
-
} // namespace Format
#endif /* _SQUID_FMT_BYTECODE_H */
case LFT_SQUID_STATUS:
if (al->http.timedout || al->http.aborted) {
- snprintf(tmp, sizeof(tmp), "%s%s", log_tags[al->cache.code],
+ snprintf(tmp, sizeof(tmp), "%s%s", LogTags_str[al->cache.code],
al->http.statusSfx());
out = tmp;
} else {
- out = log_tags[al->cache.code];
+ out = LogTags_str[al->cache.code];
}
break;
#include "SquidConfig.h"
#include "Store.h"
-const char *Format::log_tags[] = {
- "NONE",
- "TCP_HIT",
- "TCP_MISS",
- "TCP_REFRESH_UNMODIFIED",
- "TCP_REFRESH_FAIL", // same tag logged for LOG_TCP_REFRESH_FAIL_OLD and
- "TCP_REFRESH_FAIL", // LOG_TCP_REFRESH_FAIL_ERR for backward-compatibility
- "TCP_REFRESH_MODIFIED",
- "TCP_CLIENT_REFRESH_MISS",
- "TCP_IMS_HIT",
- "TCP_SWAPFAIL_MISS",
- "TCP_NEGATIVE_HIT",
- "TCP_MEM_HIT",
- "TCP_DENIED",
- "TCP_DENIED_REPLY",
- "TCP_OFFLINE_HIT",
- "TCP_REDIRECT",
- "UDP_HIT",
- "UDP_MISS",
- "UDP_DENIED",
- "UDP_INVALID",
- "UDP_MISS_NOFETCH",
- "ICP_QUERY",
- "LOG_TYPE_MAX"
-};
-
// Due to token overlaps between 1 and 2 letter tokens (Bug 3310)
// We split the token table into sets determined by the token length
namespace Format
const char *scanForToken(TokenTableEntry const table[], const char *cur);
};
-extern const char *log_tags[];
-
} // namespace Format
#endif /* _SQUID_FORMAT_TOKEN_H */
static void htcpHandleMsg(char *buf, int sz, Ip::Address &from);
-static void htcpLogHtcp(Ip::Address &, int, log_type, const char *);
+static void htcpLogHtcp(Ip::Address &, int, LogTags, const char *);
static void htcpHandleMon(htcpDataHeader *, char *buf, int sz, Ip::Address &from);
static void htcpHandleNop(htcpDataHeader *, char *buf, int sz, Ip::Address &from);
}
static void
-htcpLogHtcp(Ip::Address &caddr, int opcode, log_type logcode, const char *url)
+htcpLogHtcp(Ip::Address &caddr, int opcode, LogTags logcode, const char *url)
{
AccessLogEntry::Pointer al = new AccessLogEntry;
if (LOG_TAG_NONE == logcode)
static void icpIncomingConnectionOpened(const Comm::ConnectionPointer &conn, int errNo);
/// \ingroup ServerProtocolICPInternal2
-static void icpLogIcp(const Ip::Address &, log_type, int, const char *, int);
+static void icpLogIcp(const Ip::Address &, LogTags, int, const char *, int);
/// \ingroup ServerProtocolICPInternal2
static void icpHandleIcpV2(int, Ip::Address &, char *, int);
/// \ingroup ServerProtocolICPInternal2
static void
-icpLogIcp(const Ip::Address &caddr, log_type logcode, int len, const char *url, int delay)
+icpLogIcp(const Ip::Address &caddr, LogTags logcode, int len, const char *url, int delay)
{
AccessLogEntry::Pointer al = new AccessLogEntry();
icpUdpSend(int fd,
const Ip::Address &to,
icp_common_t * msg,
- log_type logcode,
+ LogTags logcode,
int delay)
{
icpUdpData *queue;
return ICP_ERR;
}
-log_type
+LogTags
icpLogFromICPCode(icp_opcode opcode)
{
if (opcode == ICP_ERR)
al->cache.replySize,
referer,
agent,
- ::Format::log_tags[al->cache.code],
+ LogTags_str[al->cache.code],
al->http.statusSfx(),
hier_code_str[al->hier.code],
(Config.onoff.log_mime_hdrs?"":"\n"));
al->http.version.major, al->http.version.minor,
al->http.code,
al->cache.replySize,
- ::Format::log_tags[al->cache.code],
+ LogTags_str[al->cache.code],
al->http.statusSfx(),
hier_code_str[al->hier.code],
(Config.onoff.log_mime_hdrs?"":"\n"));
(int) current_time.tv_usec / 1000,
al->cache.msec,
clientip,
- ::Format::log_tags[al->cache.code],
+ LogTags_str[al->cache.code],
al->http.statusSfx(),
al->http.code,
al->cache.replySize,
}
#endif
-
-int
-logTypeIsATcpHit(log_type code)
-{
- /* this should be a bitmap for better optimization */
-
- if (code == LOG_TCP_HIT)
- return 1;
-
- if (code == LOG_TCP_IMS_HIT)
- return 1;
-
- if (code == LOG_TCP_REFRESH_FAIL_OLD)
- return 1;
-
- if (code == LOG_TCP_REFRESH_UNMODIFIED)
- return 1;
-
- if (code == LOG_TCP_NEGATIVE_HIT)
- return 1;
-
- if (code == LOG_TCP_MEM_HIT)
- return 1;
-
- if (code == LOG_TCP_OFFLINE_HIT)
- return 1;
-
- return 0;
-}
#ifndef SQUID_LOG_ACCESS_LOG_H_
#define SQUID_LOG_ACCESS_LOG_H_
-int logTypeIsATcpHit(log_type);
+#include "LogTags.h"
+
void fvdbCountVia(const char *key);
void fvdbCountForw(const char *key);
}
storeAppendPrintf(s, "uri %s\n", http->uri);
- storeAppendPrintf(s, "logType %s\n", Format::log_tags[http->logType]);
+ storeAppendPrintf(s, "logType %s\n", LogTags_str[http->logType]);
storeAppendPrintf(s, "out.offset %ld, out.size %lu\n",
(long int) http->out.offset, (unsigned long int) http->out.size);
storeAppendPrintf(s, "req_sz %ld\n", (long int) http->req_sz);
class ClientInfo;
void clientdbInit(void) STUB
-void clientdbUpdate(const Ip::Address &, log_type, AnyP::ProtocolType, size_t) STUB
+void clientdbUpdate(const Ip::Address &, LogTags, AnyP::ProtocolType, size_t) STUB
int clientdbCutoffDenied(const Ip::Address &) STUB_RETVAL(-1)
void clientdbDump(StoreEntry *) STUB
void clientdbFreeMemory(void) STUB
bool icpAccessAllowed(Ip::Address &from, HttpRequest * icp_request) STUB_RETVAL(false)
void icpCreateAndSend(icp_opcode, int flags, char const *url, int reqnum, int pad, int fd, const Ip::Address &from) STUB
icp_opcode icpGetCommonOpcode() STUB_RETVAL(ICP_INVALID)
-int icpUdpSend(int, const Ip::Address &, icp_common_t *, log_type, int) STUB_RETVAL(0)
-log_type icpLogFromICPCode(icp_opcode opcode) STUB_RETVAL(LOG_TAG_NONE)
+int icpUdpSend(int, const Ip::Address &, icp_common_t *, LogTags, int) STUB_RETVAL(0)
+LogTags icpLogFromICPCode(icp_opcode opcode) STUB_RETVAL(LOG_TAG_NONE)
void icpDenyAccess(Ip::Address &from, char *url, int reqnum, int fd) STUB
void icpHandleIcpV3(int, Ip::Address &, char *, int) STUB
int icpCheckUdpHit(StoreEntry *, HttpRequest * request) STUB_RETVAL(0)