httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alexei Kosut <ako...@nueva.pvt.k12.ca.us>
Subject mod_log_config enhancements
Date Tue, 03 Sep 1996 01:15:14 GMT
Here's a patch that adds a couple more logging directives to
mod_log_config; I think they're useful:

%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
(and without having to use %{Cookie}i, which also gets the "Apache="
and any other cookies that might be sent).

Anyhow, thoughts?

Index: mod_cookies.c
===================================================================
RCS file: /export/home/cvs/apache/src/mod_cookies.c,v
retrieving revision 1.14
diff -c -r1.14 mod_cookies.c
*** mod_cookies.c	1996/08/24 14:41:32	1.14
--- mod_cookies.c	1996/09/03 01:11:13
***************
*** 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,389 ----
      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 ? '-' : '+');
Index: mod_log_config.c
===================================================================
RCS file: /export/home/cvs/apache/src/mod_log_config.c,v
retrieving revision 1.11
diff -c -r1.11 mod_log_config.c
*** mod_log_config.c	1996/08/27 03:34:45	1.11
--- mod_log_config.c	1996/09/03 01:11:19
***************
*** 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,258 ----
  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 ****
--- 281,289 ----
      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 ****
--- 328,340 ----
      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 ****
--- 351,367 ----
      { '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' }
  };
  


-- 
________________________________________________________________________
Alexei Kosut <akosut@nueva.pvt.k12.ca.us>      The Apache HTTP Server
URL: http://www.nueva.pvt.k12.ca.us/~akosut/   http://www.apache.org/


Mime
View raw message