method(Http::METHOD_NONE),
code(0),
content_type(NULL),
- timedout(false),
- aborted(false),
clientRequestSz(),
clientReplySz() {}
int code;
const char *content_type;
AnyP::ProtocolVersion version;
- bool timedout; ///< terminated due to a lifetime or I/O timeout
- bool aborted; ///< other abnormal termination (e.g., I/O error)
-
- /// compute suffix for the status access.log field
- const char *statusSfx() const {
- return timedout ? "_TIMEDOUT" : (aborted ? "_ABORTED" : "");
- }
/// counters for the original request received from client
// TODO calculate header and payload better (by parser)
"TYPE_MAX"
};
+/*
+ * This method is documented in http://wiki.squid-cache.org/SquidFaq/SquidLogs#Squid_result_codes
+ * Please keep the wiki up to date
+ */
const char *
LogTags::c_str() const
{
- return Str_[oldType];
+ static char buf[1024];
+ *buf = 0;
+ int pos = 0;
+
+ // source tags
+ if (oldType && oldType < LOG_TYPE_MAX)
+ pos += snprintf(buf, sizeof(buf), "%s",Str_[oldType]);
+ else
+ pos += snprintf(buf, sizeof(buf), "NONE");
+
+ // error tags
+ if (err.timedout)
+ pos += snprintf(buf+pos,sizeof(buf)-pos, "_TIMEDOUT");
+ if (err.aborted)
+ pos += snprintf(buf+pos,sizeof(buf)-pos, "_ABORTED");
+
+ return buf;
}
bool
LogTags(LogTags_ot t) : oldType(t) {assert(oldType < LOG_TYPE_MAX);}
LogTags &operator =(const LogTags_ot &t) {assert(t < LOG_TYPE_MAX); oldType = t; return *this;}
+ /// compute the status access.log field
const char *c_str() const;
/// determine if the log tag code indicates a cache HIT
bool isTcpHit() const;
+ /// error states terminating the transaction
+ struct Errors {
+ Errors() : timedout(false), aborted(false) {}
+
+ bool timedout; ///< tag: TIMEDOUT - terminated due to a lifetime or I/O timeout
+ bool aborted; ///< tag: ABORTED - other abnormal termination (e.g., I/O error)
+ } err;
+
private:
/// list of string representations for LogTags_ot
static const char *Str_[];
ClientSocketContext::noteIoError(const int xerrno)
{
if (http) {
- if (xerrno == ETIMEDOUT)
- http->al->http.timedout = true;
- else // even if xerrno is zero (which means read abort/eof)
- http->al->http.aborted = true;
+ http->logType.err.timedout = (xerrno == ETIMEDOUT);
+ // aborted even if xerrno is zero (which means read abort/eof)
+ http->logType.err.aborted = (xerrno != ETIMEDOUT);
}
}
ClientHttpRequest *http = static_cast<ClientHttpRequest *>(io.data);
debugs(33, DBG_IMPORTANT, "WARNING: Closing client connection due to lifetime timeout");
debugs(33, DBG_IMPORTANT, "\t" << http->uri);
- http->al->http.timedout = true;
+ http->logType.err.timedout = true;
if (Comm::IsConnOpen(io.conn))
io.conn->close();
}
break;
case LFT_SQUID_STATUS:
- if (al->http.timedout || al->http.aborted) {
- snprintf(tmp, sizeof(tmp), "%s%s", al->cache.code.c_str(), al->http.statusSfx());
- out = tmp;
- } else {
- out = al->cache.code.c_str();
- }
-
+ out = al->cache.code.c_str();
break;
case LFT_SQUID_ERROR:
else
method = al->http.method.image();
- logfilePrintf(logfile, "%s %s %s [%s] \"" SQUIDSBUFPH " %s %s/%d.%d\" %d %" PRId64 " \"%s\" \"%s\" %s%s:%s%s",
+ logfilePrintf(logfile, "%s %s %s [%s] \"" SQUIDSBUFPH " %s %s/%d.%d\" %d %" PRId64 " \"%s\" \"%s\" %s:%s%s",
clientip,
user_ident ? user_ident : dash_str,
user_auth ? user_auth : dash_str,
referer,
agent,
al->cache.code.c_str(),
- al->http.statusSfx(),
hier_code_str[al->hier.code],
(Config.onoff.log_mime_hdrs?"":"\n"));
else
method = al->http.method.image();
- logfilePrintf(logfile, "%s %s %s [%s] \"" SQUIDSBUFPH " %s %s/%d.%d\" %d %" PRId64 " %s%s:%s%s",
+ logfilePrintf(logfile, "%s %s %s [%s] \"" SQUIDSBUFPH " %s %s/%d.%d\" %d %" PRId64 " %s:%s%s",
clientip,
user_ident ? user_ident : dash_str,
user_auth ? user_auth : dash_str,
al->http.code,
al->http.clientReplySz.messageTotal(),
al->cache.code.c_str(),
- al->http.statusSfx(),
hier_code_str[al->hier.code],
(Config.onoff.log_mime_hdrs?"":"\n"));
else
method = al->http.method.image();
- logfilePrintf(logfile, "%9ld.%03d %6ld %s %s%s/%03d %" PRId64 " " SQUIDSBUFPH " %s %s %s%s/%s %s%s",
+ logfilePrintf(logfile, "%9ld.%03d %6ld %s %s/%03d %" PRId64 " " SQUIDSBUFPH " %s %s %s%s/%s %s%s",
(long int) current_time.tv_sec,
(int) current_time.tv_usec / 1000,
tvToMsec(al->cache.trTime),
clientip,
al->cache.code.c_str(),
- al->http.statusSfx(),
al->http.code,
al->http.clientReplySz.messageTotal(),
SQUIDSBUFPRINT(method),