diff -ur squid-2.4.STABLE3-orig/src/access_log.c squid-2.4.STABLE3/src/access_log.c --- squid-2.4.STABLE3-orig/src/access_log.c Thu Jan 11 16:51:44 2001 +++ squid-2.4.STABLE3/src/access_log.c Thu Jun 27 03:23:42 2002 @@ -38,6 +38,7 @@ static void accessLogSquid(AccessLogEntry * al); static void accessLogCommon(AccessLogEntry * al); +static void accessLogCombined(clientHttpRequest * http); static Logfile *logfile = NULL; #if HEADERS_LOG static Logfile *headerslog = NULL; @@ -228,8 +229,41 @@ hier_strings[al->hier.code]); } +static void +accessLogCombined(clientHttpRequest * http) +{ + const char *client = NULL; + AccessLogEntry * al; + char *referer = httpHeaderGetStr(&http->request->header, HDR_REFERER); + char *user_agent = httpHeaderGetStr(&http->request->header, HDR_USER_AGENT); + if (referer == NULL) + referer = "-"; + if (user_agent == NULL) + user_agent = "-"; + debug(46, 1) ("accessLogCombined: Referer = \"%s\"\n", referer); + debug(46, 1) ("accessLogCombined: User Agent = \"%s\"\n", user_agent); + al = &http->al; + if (Config.onoff.log_fqdn) + client = fqdncache_gethostbyaddr(al->cache.caddr, 0); + if (client == NULL) + client = inet_ntoa(al->cache.caddr); + logfilePrintf(logfile, "%s %s - [%s] \"%s %s HTTP/%d.%d\" %d %d \"%s\" \"%s\" %s:%s", + client, + al->cache.ident, + mkhttpdlogtime(&squid_curtime), + al->private.method_str, + al->url, + al->http.version.major, al->http.version.minor, + al->http.code, + al->cache.size, + referer, + user_agent, + log_tags[al->cache.code], + hier_strings[al->hier.code]); +} + void -accessLogLog(AccessLogEntry * al) +accessLogLog(AccessLogEntry * al, clientHttpRequest * http) { LOCAL_ARRAY(char, ident_buf, USER_IDENT_SZ); @@ -252,10 +286,14 @@ if (al->hier.host[0] == '\0') xstrncpy(al->hier.host, dash_str, SQUIDHOSTNAMELEN); - if (Config.onoff.common_log) - accessLogCommon(al); - else - accessLogSquid(al); + if (Config.onoff.common_log) { + accessLogCommon(al); + } else if (Config.onoff.combined_log && http != NULL) { + debug(46, 1) ("Using combined log format\n"); + accessLogCombined(http); + } else { + accessLogSquid(al); + } if (Config.onoff.log_mime_hdrs) { char *ereq = log_quote(al->headers.request); char *erep = log_quote(al->headers.reply); diff -ur squid-2.4.STABLE3-orig/src/cf.data.pre squid-2.4.STABLE3/src/cf.data.pre --- squid-2.4.STABLE3-orig/src/cf.data.pre Wed Apr 4 00:01:12 2001 +++ squid-2.4.STABLE3/src/cf.data.pre Thu Jun 27 01:26:11 2002 @@ -822,6 +822,19 @@ information that Squid-specific log analyzers use. DOC_END +NAME: emulate_apache_log +COMMENT: on|off +TYPE: onoff +DEFAULT: off +LOC: Config.onoff.combined_log +DOC_START + Similar in operation to the emulate_httpd_log configuration + option, this directive creates the Apache Combined Log Format + which includes the regular common_log information with the + referrer and useragent information. This cannot be used with + emulate_httpd_log, and the default is off. +DOC_END + NAME: log_ip_on_direct COMMENT: on|off TYPE: onoff diff -ur squid-2.4.STABLE3-orig/src/client_side.c squid-2.4.STABLE3/src/client_side.c --- squid-2.4.STABLE3-orig/src/client_side.c Fri Apr 20 16:21:41 2001 +++ squid-2.4.STABLE3/src/client_side.c Thu Jun 27 02:51:34 2002 @@ -746,7 +746,7 @@ packerClean(&p); memBufClean(&mb); } - accessLogLog(&http->al); + accessLogLog(&http->al, http); clientUpdateCounters(http); clientdbUpdate(conn->peer.sin_addr, http->log_type, PROTO_HTTP, http->out.size); } diff -ur squid-2.4.STABLE3-orig/src/icp_v2.c squid-2.4.STABLE3/src/icp_v2.c --- squid-2.4.STABLE3-orig/src/icp_v2.c Thu Jan 11 16:51:49 2001 +++ squid-2.4.STABLE3/src/icp_v2.c Thu Jun 27 02:08:30 2002 @@ -63,7 +63,7 @@ al.cache.size = len; al.cache.code = logcode; al.cache.msec = delay; - accessLogLog(&al); + accessLogLog(&al, NULL); } void diff -ur squid-2.4.STABLE3-orig/src/protos.h squid-2.4.STABLE3/src/protos.h --- squid-2.4.STABLE3-orig/src/protos.h Sun Sep 9 12:59:28 2001 +++ squid-2.4.STABLE3/src/protos.h Thu Jun 27 02:09:03 2002 @@ -31,7 +31,7 @@ * */ -extern void accessLogLog(AccessLogEntry *); +extern void accessLogLog(AccessLogEntry *, clientHttpRequest *); extern void accessLogRotate(void); extern void accessLogClose(void); extern void accessLogInit(void); diff -ur squid-2.4.STABLE3-orig/src/structs.h squid-2.4.STABLE3/src/structs.h --- squid-2.4.STABLE3-orig/src/structs.h Mon Oct 8 08:22:03 2001 +++ squid-2.4.STABLE3/src/structs.h Thu Jun 27 01:18:24 2002 @@ -407,6 +407,7 @@ int source_ping; #endif int common_log; + int combined_log; int log_mime_hdrs; int log_fqdn; int announce;