Received: (qmail 94308 invoked by uid 501); 3 Feb 2001 21:50:38 -0000 Message-Id: <20010203215038.94307.qmail@apache.org> Date: 3 Feb 2001 21:50:38 -0000 From: Helge Oldach Reply-To: apache@oldach.net To: submit@bugz.apache.org Subject: suggested improvement to log modification date for cached files X-Send-Pr-Version: 3.110 >Number: 7185 >Category: mod_proxy >Synopsis: suggested improvement to log modification date for cached files >Confidential: no >Severity: non-critical >Priority: medium >Responsible: apache >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: unknown >Arrival-Date: Sat Feb 03 14:00:00 PST 2001 >Closed-Date: >Last-Modified: >Originator: apache@oldach.net >Release: 1.3.17 >Organization: apache >Environment: FreeBSD sep.oldach.net 4.2-STABLE FreeBSD 4.2-STABLE #0: Sat Jan 20 13:43:48 CET 2001 toor@sep.oldach.net:/usr/obj/usr/src/sys/HMO i386 >Description: This patch adds a '%{format}M' configurable log directive similar to '%{format}t'. It prints into the modification time (r->mtime) of the request. This is being filled in by mod_proxy with the time when the cached file (if any) was last touched. Basically this is a hack to allow to distinguish between requests served from the cache (time != 0) and requests served from the net (time == 0). It also delivers a rough estimate of the age of the cached files that are actually used. >How-To-Repeat: >Fix: --- src/modules/proxy/mod_proxy.c.orig Mon Jan 15 18:05:27 2001 +++ src/modules/proxy/mod_proxy.c Sat Feb 3 21:49:09 2001 @@ -325,8 +325,10 @@ return HTTP_BAD_REQUEST; rc = ap_proxy_cache_check(r, url, &conf->cache, &cr); - if (rc != DECLINED) + if (rc != DECLINED) { + r->mtime = cr->date; return rc; + } /* If the host doesn't have a domain name, add one and redirect. */ if (conf->domain != NULL) {--- src/modules/standard/mod_log_config.c.orig Mon Jan 15 18:05:44 2001 +++ src/modules/standard/mod_log_config.c Sat Feb 3 21:59:06 2001 @@ -439,6 +439,33 @@ return ap_pstrdup(r->pool, tstr); } +static const char *log_request_mtime(request_rec *r, char *a) +{ + int timz; + struct tm *t; + char tstr[MAX_STRING_LEN]; + + t = ap_get_gmtoff(&timz); + t = localtime(&r->mtime); + + if (a && *a) { /* Custom format */ + strftime(tstr, MAX_STRING_LEN, a, t); + } + else { /* CLF format */ + char sign = (timz < 0 ? '-' : '+'); + + if (timz < 0) { + timz = -timz; + } + ap_snprintf(tstr, sizeof(tstr), "[%02d/%s/%d:%02d:%02d:%02d %c%.2d%.2d]", + t->tm_mday, ap_month_snames[t->tm_mon], t->tm_year+1900, + t->tm_hour, t->tm_min, t->tm_sec, + sign, timz / 60, timz % 60); + } + + return ap_pstrdup(r->pool, tstr); +} + static const char *log_request_duration(request_rec *r, char *a) { return ap_psprintf(r->pool, "%ld", time(NULL) - r->request_time); @@ -513,6 +540,9 @@ }, { 'T', log_request_duration, 1 + }, + { + 'M', log_request_mtime, 1 }, { 'r', log_request_line, 1 >Release-Note: >Audit-Trail: >Unformatted: [In order for any reply to be added to the PR database, you need] [to include in the Cc line and make sure the] [subject line starts with the report component and number, with ] [or without any 'Re:' prefixes (such as "general/1098:" or ] ["Re: general/1098:"). If the subject doesn't match this ] [pattern, your message will be misfiled and ignored. The ] ["apbugs" address is not added to the Cc line of messages from ] [the database automatically because of the potential for mail ] [loops. If you do not include this Cc, your reply may be ig- ] [nored unless you are responding to an explicit request from a ] [developer. Reply only with text; DO NOT SEND ATTACHMENTS! ]