Re: [squid-users] Customize LogFormat patch not work

From: Miros�aw Jaworski <[email protected]>
Date: Wed, 9 Jun 2004 10:20:39 +0200

Cytowanie Mrvka Andreas <mrv@tuev.at>:

> Hi guys,
>
> i use awstats and wanted to analyse squid 2.5-Stable5.
> i heard to use a patch for customizable logformat.

Hi

About year ago I was looking for a working patch and didn't find one, so
I came up with my own hard hack, which causes squid to generate exact apache's
combined log instead of "common apache plus some squid fields" log when
you turn apache emulation logging on.

3 small changes below, plus "emulate_httpd_log on" in your squid.conf
should do the trick.

It's against squid-2.5.STABLE3:

# diff -cr src/structs.h.orig src/structs.h
*** src/structs.h.orig Wed Jun 4 14:13:31 2003
--- src/structs.h Wed Jun 4 14:14:44 2003
***************
*** 1025,1030 ****
--- 1025,1032 ----
        int code;
        const char *content_type;
        http_version_t version;
+ const char *agent;
+ const char *referer;
      } http;
      struct {
        icp_opcode opcode;

# diff -cr src/client_side.c.orig src/client_side.c
*** src/client_side.c.orig Wed Jun 4 14:09:57 2003
--- src/client_side.c Wed Jun 4 15:19:13 2003
***************
*** 779,784 ****
--- 779,785 ----
      ConnStateData *conn = http->conn;
      StoreEntry *e;
      request_t *request = http->request;
+ const HttpHeader *req_hdr = &request->header;
      MemObject *mem = NULL;
      debug(33, 3) ("httpRequestFree: %s\n", storeUrl(http->entry));
      if (!clientCheckTransferDone(http)) {
***************
*** 805,810 ****
--- 806,813 ----
        http->al.cache.size = http->out.size;
        http->al.cache.code = http->log_type;
        http->al.cache.msec = tvSubMsec(http->start, current_time);
+ http->al.http.agent = httpHeaderGetStr(req_hdr, HDR_USER_AGENT);
+ http->al.http.referer = httpHeaderGetStr(req_hdr, HDR_REFERER);
        if (request) {
            Packer p;
            MemBuf mb;

# diff -cr src/access_log.c.orig src/access_log.c
*** src/access_log.c.orig Wed Jun 4 14:06:01 2003
--- src/access_log.c Wed Jun 4 15:19:55 2003
***************
*** 271,277 ****
        client = inet_ntoa(al->cache.caddr);
      user1 = accessLogFormatName(al->cache.authuser);
      user2 = accessLogFormatName(al->cache.rfc931);
! logfilePrintf(logfile, "%s %s %s [%s] \"%s %s HTTP/%d.%d\" %d %ld %s:%s",
        client,
        user2 ? user2 : dash_str,
        user1 ? user1 : dash_str,
--- 271,277 ----
        client = inet_ntoa(al->cache.caddr);
      user1 = accessLogFormatName(al->cache.authuser);
      user2 = accessLogFormatName(al->cache.rfc931);
! logfilePrintf(logfile, "%s %s %s [%s] \"%s %s HTTP/%d.%d\" %d %ld \"%s\"
\"%s\"",
        client,
        user2 ? user2 : dash_str,
        user1 ? user1 : dash_str,
***************
*** 281,288 ****
        al->http.version.major, al->http.version.minor,
        al->http.code,
        (long int) al->cache.size,
! log_tags[al->cache.code],
! hier_strings[al->hier.code]);
      safe_free(user1);
      safe_free(user2);
  }
--- 281,288 ----
        al->http.version.major, al->http.version.minor,
        al->http.code,
        (long int) al->cache.size,
! al->http.referer ? al->http.referer : dash_str,
! al->http.agent ? al->http.agent : dash_str );
      safe_free(user1);
      safe_free(user2);
  }

Regards

M.

-- 
Miroslaw.Jaworski@gts.pl  ( Psyborg )  MJ102-RIPE  GTS Internet Partners SA
Servers Administration Department Manager
Received on Wed Jun 09 2004 - 02:21:01 MDT

This archive was generated by hypermail pre-2.1.9 : Thu Jul 01 2004 - 12:00:02 MDT