Hi All!
Michal Matusiak [mm189421@students.mimuw.edu.pl] has wrote a patch - extacclog-patch2.diff.
This patch makes squid write information in access.log with defined accloggran (new TAG in squid.conf).
It also makes squid write information about client port (during downloading).
I've made some changes in this patch to avoid access.log format changes ( - extacclog2.diff - new name for patch). And I need help. Could somebody test it for bugs, or may be optimize it a bit. This patch wokrs just fine on my squid but there were some problems on other servers.
extacclog2.diff:
diff -Nur squid-2.5.STABLE5/acconfig.h squid-extacclog/acconfig.h
--- squid-2.5.STABLE5/acconfig.h 2002-07-01 10:55:11.000000000 +0200
+++ squid-extacclog/acconfig.h 2004-06-26 16:25:34.000000000 +0200
@@ -95,6 +95,11 @@
#undef USE_USERAGENT_LOG
/*
+ * Define this if you want extended access logging support.
+ */
+#undef USE_EXTACCLOG
+
+/*
* If you want to log Referer request header values, define this.
* By default, they are written to referer.log in the Squid log
* directory.
diff -Nur squid-2.5.STABLE5/configure.in squid-extacclog/configure.in
--- squid-2.5.STABLE5/configure.in 2004-02-29 23:30:21.000000000 +0100
+++ squid-extacclog/configure.in 2004-06-27 21:17:00.000000000 +0200
@@ -451,6 +451,16 @@
fi
])
+AM_CONDITIONAL(USE_EXTACCLOG, false)
+AC_ARG_ENABLE(extacclog,
+[ --enable-extacclog Enable extended access logging],
+[ if test "$enableval" = "yes" ; then
+ echo "Extended access logging enabled"
+ AC_DEFINE(USE_EXTACCLOG)
+ AM_CONDITIONAL(USE_EXTACCLOG, true)
+ fi
+])
+
AC_ARG_ENABLE(referer-log,
[ --enable-referer-log Enable logging of Referer header],
[ if test "$enableval" = "yes" ; then
diff -Nur squid-2.5.STABLE5/include/autoconf.h.in squid-extacclog/include/autoconf.h.in
--- squid-2.5.STABLE5/include/autoconf.h.in 2003-01-18 02:46:33.000000000 +0100
+++ squid-extacclog/include/autoconf.h.in 2004-06-27 21:17:39.000000000 +0200
@@ -132,6 +132,11 @@
#undef USE_USERAGENT_LOG
/*
+ * Define this if you want extended access logging support.
+ */
+#undef USE_EXTACCLOG
+
+/*
* If you want to log Referer request header values, define this.
* By default, they are written to referer.log in the Squid log
* directory.
diff -Nur squid-2.5.STABLE5/src/access_log.c squid-extacclog/src/access_log.c
--- squid-2.5.STABLE5/src/access_log.c 2003-07-28 10:59:28.000000000 +0200
+++ squid-extacclog/src/access_log.c 2004-06-26 17:57:22.000000000 +0200
@@ -245,4 +245,8 @@
client = inet_ntoa(al->cache.caddr);
user = accessLogFormatName(al->cache.authuser ?
al->cache.authuser : al->cache.rfc931);
+#if USE_EXTACCLOG
+ logfilePrintf(logfile, "%9d.%03d %6d %s %s/%03d %ld %s %s %s %s%s/%s %s %d",
+#else
logfilePrintf(logfile, "%9d.%03d %6d %s %s/%03d %ld %s %s %s %s%s/%s %s",
+#endif
@@ -262,1 +262,6 @@
- al->http.content_type);
+#if USE_EXTACCLOG
+ al->http.content_type,
+ al->cache.cport); /* write client-port in the end of log string*/
+#else
+ al->http.content_type);
+#endif
diff -Nur squid-2.5.STABLE5/src/cf.data.pre squid-extacclog/src/cf.data.pre
--- squid-2.5.STABLE5/src/cf.data.pre 2004-02-10 22:01:21.000000000 +0100
+++ squid-extacclog/src/cf.data.pre 2004-06-27 21:10:53.000000000 +0200
@@ -837,6 +837,16 @@
every HTTP and ICP queries received. To disable, enter "none".
DOC_END
+NAME: accloggran
+COMMENT: (KB)
+TYPE: kb_size_t
+DEFAULT: 1024 KB
+IFDEF: USE_EXTACCLOG
+LOC: Config.Log.accloggranulation
+DOC_START
+ How often squid access-logs.
+DOC_END
+
NAME: cache_log
TYPE: string
diff -Nur squid-2.5.STABLE5/src/client_side.c squid-extacclog/src/client_side.c
--- squid-2.5.STABLE5/src/client_side.c 2004-02-18 19:51:16.000000000 +0100
+++ squid-extacclog/src/client_side.c 2004-07-02 00:12:01.000000000 +0200
@@ -834,8 +834,15 @@
http->al.http.code = mem->reply->sline.status;
http->al.http.content_type = strBuf(mem->reply->content_type);
}
+#if USE_EXTACCLOG
+ http->al.cache.cport = ntohs(conn->peer.sin_port);
+#endif
http->al.cache.caddr = conn->log_addr;
+#if USE_EXTACCLOG
+ http->al.cache.size = http->out.last_size;
+#else
http->al.cache.size = http->out.size;
+#endif
http->al.cache.code = http->log_type;
http->al.cache.msec = tvSubMsec(http->start, current_time);
if (request) {
@@ -2178,8 +2185,16 @@
{
clientHttpRequest *http = data;
StoreEntry *entry = http->entry;
+#if USE_EXTACCLOG
+ MemObject *mem = NULL;
+ ConnStateData *conn = http->conn;
+ request_t *request = http->request;
+#endif
int done;
http->out.size += size;
+#if USE_EXTACCLOG
+ http->out.last_size += size;
+#endif
debug(33, 5) ("clientWriteComplete: FD %d, sz %ld, err %d, off %ld, len %d\n",
fd, (long int) size, errflag, (long int) http->out.offset, entry ? objectLen(entry) : 0);
if (size > 0) {
@@ -2187,6 +2202,49 @@
if (isTcpHit(http->log_type))
kb_incr(&statCounter.client_http.hit_kbytes_out, size);
}
+#if USE_EXTACCLOG
+ if (http->out.last_size > (Config.Log.accloggranulation << 10))
+ {
+ if (http->entry)
+ mem = http->entry->mem_obj;
+ if (http->out.size || http->log_type) {
+ http->al.icp.opcode = ICP_INVALID;
+ http->al.url = http->log_uri;
+ if (mem) {
+ http->al.http.code = mem->reply->sline.status;
+ http->al.http.content_type = strBuf(mem->reply->content_type);
+ }
+ http->al.cache.cport = ntohs(conn->peer.sin_port);
+ http->al.cache.caddr = conn->log_addr;
+ http->al.cache.size = http->out.last_size;
+ http->out.last_size = 0;
+ http->al.cache.code = http->log_type;
+ http->al.cache.msec = tvSubMsec(http->start, current_time);
+ if (request) {
+ Packer p;
+ MemBuf mb;
+ memBufDefInit(&mb);
+ packerToMemInit(&p, &mb);
+ httpHeaderPackInto(&request->header, &p);
+ http->al.http.method = request->method;
+ http->al.http.version = request->http_ver;
+ http->al.headers.request = xstrdup(mb.buf);
+ http->al.hier = request->hier;
+ if (request->auth_user_request) {
+ if (authenticateUserRequestUsername(request->auth_user_request))
+ http->al.cache.authuser = xstrdup(authenticateUserRequestUsername(request->auth_user_request));
+ authenticateAuthUserRequestUnlock(request->auth_user_request);
+ request->auth_user_request = NULL;
+ }
+ if (conn->rfc931[0])
+ http->al.cache.rfc931 = conn->rfc931;
+ packerClean(&p);
+ memBufClean(&mb);
+ }
+ accessLogLog(&http->al);
+ }
+}
+#endif
#if SIZEOF_SIZE_T == 4
if (http->out.size > 0x7FFF0000) {
debug(33, 1) ("WARNING: closing FD %d to prevent counter overflow\n", fd);
diff -Nur squid-2.5.STABLE5/src/structs.h squid-extacclog/src/structs.h
--- squid-2.5.STABLE5/src/structs.h 2004-02-04 18:42:28.000000000 +0100
+++ squid-extacclog/src/structs.h 2004-07-01 23:57:59.000000000 +0200
@@ -467,6 +467,9 @@
char *forward;
#endif
int rotateNumber;
+#if USE_EXTACCLOG
+ size_t accloggranulation;
+#endif
} Log;
char *adminEmail;
char *effectiveUser;
@@ -1036,6 +1039,9 @@
icp_opcode opcode;
} icp;
struct {
+#if USE_EXTACCLOG
+ unsigned short cport;
+#endif
struct in_addr caddr;
size_t size;
log_type code;
@@ -1063,6 +1069,9 @@
struct {
off_t offset;
size_t size;
+#if USE_EXTACCLOG
+ size_t last_size;
+#endif
} out;
HttpHdrRangeIter range_iter; /* data for iterating thru range specs */
size_t req_sz; /* raw request size on input, not current request size */
Received on Tue Sep 07 2004 - 23:41:26 MDT
This archive was generated by hypermail pre-2.1.9 : Thu Sep 30 2004 - 12:00:04 MDT