mjc 96/09/26 04:31:03
Modified: src mod_cookies.c mod_log_config.c
Log:
Submitted by: Alexei Kosut
Reviewed by: Mark Cox
Add some more useful directives for logging.
%U: the URL path that was requested
%f: the filename.
%P: the PID of the child that served the request (this might be useful
for tracking the BROKEN_WAIT problem; I dunno.)
It also adds a %{...}n directive that returns the contents of a note
(from the r->notes table). The idea of this is that modules can set
notes with data to be logged. This patch, as an example, has
mod_cookies put its cookie into a note called "cookie". This allows
mod_log_config to log it without having to use a seperate cookie log
Revision Changes Path
1.16 +5 -3 apache/src/mod_cookies.c
Index: mod_cookies.c
===================================================================
RCS file: /export/home/cvs/apache/src/mod_cookies.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -C3 -r1.15 -r1.16
*** mod_cookies.c 1996/09/08 12:25:30 1.15
--- mod_cookies.c 1996/09/26 11:31:00 1.16
***************
*** 50,56 ****
*
*/
! /* $Id: mod_cookies.c,v 1.15 1996/09/08 12:25:30 ben Exp $ */
/* User Tracking Module
*
--- 50,56 ----
*
*/
! /* $Id: mod_cookies.c,v 1.16 1996/09/26 11:31:00 mjc Exp $ */
/* User Tracking Module
*
***************
*** 368,375 ****
for (r = orig; r->next; r = r->next)
continue;
- if (*cls->fname == '\0') /* Don't log cookies */
- return DECLINED;
if (!(cookie = table_get (r->headers_in, "Cookie")))
return DECLINED; /* Theres no cookie, don't bother logging */
--- 368,373 ----
***************
*** 380,385 ****
--- 378,387 ----
cookiebuf=pstrdup( r->pool, value );
cookieend=strchr(cookiebuf,';');
if (cookieend) *cookieend='\0'; /* Ignore anything after a ; */
+ /* Set the cookie in a note, in case we log it seperately */
+ table_set(r->notes, "cookie", cookiebuf);
+ if (*cls->fname == '\0') /* Don't log cookies */
+ return DECLINED;
t = get_gmtoff(&timz);
sign = (timz < 0 ? '-' : '+');
1.12 +20 -1 apache/src/mod_log_config.c
Index: mod_log_config.c
===================================================================
RCS file: /export/home/cvs/apache/src/mod_log_config.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -C3 -r1.11 -r1.12
*** mod_log_config.c 1996/08/27 03:34:45 1.11
--- mod_log_config.c 1996/09/26 11:31:01 1.12
***************
*** 50,56 ****
*
*/
! /* $Id: mod_log_config.c,v 1.11 1996/08/27 03:34:45 akosut Exp $ */
/*
* This is module implements the TransferLog directive (same as the
--- 50,56 ----
*
*/
! /* $Id: mod_log_config.c,v 1.12 1996/09/26 11:31:01 mjc Exp $ */
/*
* This is module implements the TransferLog directive (same as the
***************
*** 109,120 ****
--- 109,123 ----
* follows:
*
* %...b: bytes sent.
+ * %...f: filename
* %...h: remote host
* %...{Foobar}i: The contents of Foobar: header line(s) in the request
* sent to the client.
* %...l: remote logname (from identd, if supplied)
+ * %...{Foobar}n: The contents of note "Foobar" from another module.
* %...{Foobar}o: The contents of Foobar: header line(s) in the reply.
* %...p: the port the request was served to
+ * %...P: the process ID of the child that serviced the request.
* %...r: first line of request
* %...s: status. For requests that got internally redirected, this
* is status of the *original* request --- %...>s for the last.
***************
*** 123,128 ****
--- 126,132 ----
* be in strftime(3) format.
* %...T: the time taken to serve the request, in seconds.
* %...u: remote user (from auth; may be bogus if return status (%s) is
401)
+ * %...U: the URL path requested.
* %...v: the name of the server (i.e. which virtual host?)
*
* The '...' can be nothing at all (e.g. "%h %u %r %s %b"), or it can
***************
*** 243,248 ****
--- 247,256 ----
char *log_request_line (request_rec *r, char *a)
{ return r->the_request; }
+ char *log_request_file (request_rec *r, char *a)
+ { return r->filename; }
+ char *log_request_uri (request_rec *r, char *a)
+ { return r->uri; }
char *log_status (request_rec *r, char *a)
{ return pfmt(r->pool, r->status); }
***************
*** 271,276 ****
--- 279,286 ----
return table_get (r->err_headers_out, a);
}
+ char *log_note (request_rec *r, char *a)
+ { return table_get (r->notes, a); }
char *log_env_var (request_rec *r, char *a)
{ return table_get (r->subprocess_env, a); }
***************
*** 315,320 ****
--- 325,335 ----
return pstrdup(r->pool, portnum);
}
+ char *log_child_pid (request_rec *r, char *a) {
+ char pidnum[10];
+ sprintf(pidnum, "%ld", getpid());
+ return pstrdup(r->pool, pidnum);
+ }
/*****************************************************************
*
* Parsing the log format string
***************
*** 331,343 ****
--- 346,362 ----
{ 't', log_request_time, 0 },
{ 'T', log_request_duration, 0 },
{ 'r', log_request_line, 1 },
+ { 'f', log_request_file, 0 },
+ { 'U', log_request_uri, 1 },
{ 's', log_status, 1 },
{ 'b', log_bytes_sent, 0 },
{ 'i', log_header_in, 0 },
{ 'o', log_header_out, 0 },
+ { 'n', log_note, 0 },
{ 'e', log_env_var, 0 },
{ 'v', log_virtual_host, 0 },
{ 'p', log_server_port, 0 },
+ { 'P', log_child_pid, 0 },
{ '\0' }
};