]> granicus.if.org Git - apache/commitdiff
change the way that thread id is specified in the log format since
authorJeff Trawick <trawick@apache.org>
Fri, 18 Apr 2003 19:40:11 +0000 (19:40 +0000)
committerJeff Trawick <trawick@apache.org>
Fri, 18 Apr 2003 19:40:11 +0000 (19:40 +0000)
the previous implementation used a format string already taken
by mod_logio

now, an optional %P format is used instead

thanks to Andre' Malo for pointing out that I chose a format string
already used by mod_logio!

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@99442 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
docs/manual/mod/mod_log_config.html.en
docs/manual/mod/mod_log_config.xml
modules/loggers/mod_log_config.c

diff --git a/CHANGES b/CHANGES
index fbffb8627d668c5fd0c4041417ff44843824d8d9..38e182aabb6949cbe17d2dddf2eb9cd4ce82c30d 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -3,7 +3,7 @@ Changes with Apache 2.1.0-dev
   [Remove entries to the current 2.0 section below, when backported]
 
   *) mod_log_config: Add the ability to log the id of the thread 
-     processing the request (%I).  [Jeff Trawick]
+     processing the request via new %P formats.  [Jeff Trawick]
 
   *) Fix a problem that caused httpd to linked with incorrect flags
      on some platforms when mod_so was enabled by default, breaking 
index 62624559e22bfd01bea18174e83463eef41e4e2e..c8685fc95f72f229721e5a9643a7e23b7935cba1 100644 (file)
         <td>Remote host</td></tr>
 <tr><td><code>%...H</code></td>
         <td>The request protocol</td></tr>
-<tr class="odd"><td><code>%...I</code></td>
-        <td>The thread id if APR supports threads, otherwise 0</td></tr>
-<tr><td><code>%...{<var>Foobar</var>}i</code></td>
+<tr class="odd"><td><code>%...{<var>Foobar</var>}i</code></td>
         <td>The contents of <code><var>Foobar</var>:</code> header line(s)
         in the request sent to the server.</td></tr>
-<tr class="odd"><td><code>%...l</code></td>
+<tr><td><code>%...l</code></td>
         <td>Remote logname (from identd, if supplied). This will return a
         dash unless <code class="module"><a href="../mod/mod_ident.html">mod_ident</a></code> is present and <code class="directive"><a href="../mod/mod_ident.html#identitycheck">IdentityCheck</a></code> is set
         <code>On</code>.</td></tr>
-<tr><td><code>%...m</code></td>
+<tr class="odd"><td><code>%...m</code></td>
         <td>The request method</td></tr>
-<tr class="odd"><td><code>%...{<var>Foobar</var>}n</code></td>
+<tr><td><code>%...{<var>Foobar</var>}n</code></td>
         <td>The contents of note <var>Foobar</var> from another
         module.</td></tr>
-<tr><td><code>%...{<var>Foobar</var>}o</code></td>
+<tr class="odd"><td><code>%...{<var>Foobar</var>}o</code></td>
         <td>The contents of <code><var>Foobar</var>:</code> header line(s)
         in the reply.</td></tr>
-<tr class="odd"><td><code>%...p</code></td>
+<tr><td><code>%...p</code></td>
         <td>The canonical port of the server serving the request</td></tr>
-<tr><td><code>%...P</code></td>
+<tr class="odd"><td><code>%...P</code></td>
         <td>The process ID of the child that serviced the request.</td></tr>
+<tr><td><code>%...{<var>format</var>}P</code></td>
+        <td>The process ID and or thread id of the child that serviced the 
+        request.  Valid formats are <code>pid</code>, <code>tid</code>,
+        and <code>pid/tid</code>.</td></tr>
 <tr class="odd"><td><code>%...q</code></td>
         <td>The query string (prepended with a <code>?</code> if a query
         string exists, otherwise an empty string)</td></tr>
index 846f6c0041ce6ebb34091aacf9407eb4cd12d435..49ff38dbb3eeb99f2c3e11776736a6aede7caa2b 100644 (file)
@@ -83,9 +83,6 @@
     <tr><td><code>%...H</code></td>
         <td>The request protocol</td></tr>
 
-    <tr><td><code>%...I</code></td>
-        <td>The thread id if APR supports threads, otherwise 0</td></tr>
-
     <tr><td><code>%...{<var>Foobar</var>}i</code></td>
         <td>The contents of <code><var>Foobar</var>:</code> header line(s)
         in the request sent to the server.</td></tr>
     <tr><td><code>%...P</code></td>
         <td>The process ID of the child that serviced the request.</td></tr>
 
+    <tr><td><code>%...{<var>format</var>}P</code></td>
+        <td>The process ID and or thread id of the child that serviced the 
+        request.  Valid formats are <code>pid</code>, <code>tid</code>,
+        and <code>pid/tid</code>.</td></tr>
+
     <tr><td><code>%...q</code></td>
         <td>The query string (prepended with a <code>?</code> if a query
         string exists, otherwise an empty string)</td></tr>
index 9b4627a801d1732254d49d7efb3a7fa849920fd3..85aae5a09efeb9a1186bf9e89caa92e8efdc6313 100644 (file)
@@ -613,20 +613,28 @@ static const char *log_server_name(request_rec *r, char *a)
     return ap_escape_logitem(r->pool, ap_get_server_name(r));
 }
 
-static const char *log_child_pid(request_rec *r, char *a)
-{
-    return apr_psprintf(r->pool, "%ld", (long) getpid());
-}
-
-static const char *log_tid(request_rec *r, char *a)
+static const char *log_pid_tid(request_rec *r, char *a)
 {
+    if (*a == '\0' || !strcmp(a, "pid")) {
+        return apr_psprintf(r->pool, "%ld", (long)getpid());
+    }
+    else {
 #if APR_HAS_THREADS
-    apr_os_thread_t tid = apr_os_thread_current();
-
-    return apr_psprintf(r->pool, "%pT", &tid);
+        apr_os_thread_t tid = apr_os_thread_current();
 #else
-    return "0";
+        int tid = 0; /* APR will format "0" anyway but an arg is needed */
 #endif
+
+        if (!strcmp(a, "pid/tid")) {
+            return apr_psprintf(r->pool, "%ld/%pT", (long)getpid(), &tid);
+        }
+        else if (!strcmp(a, "tid")) {
+            return apr_psprintf(r->pool, "%pT", &tid);
+        }
+        else { /* bogus string */
+            return a;
+        }
+    }
 }
 
 static const char *log_connection_status(request_rec *r, char *a)
@@ -1393,8 +1401,7 @@ static int log_pre_config(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp)
         log_pfn_register(p, "V", log_server_name, 0);
         log_pfn_register(p, "v", log_virtual_host, 0);
         log_pfn_register(p, "p", log_server_port, 0);
-        log_pfn_register(p, "P", log_child_pid, 0);
-        log_pfn_register(p, "I", log_tid, 0);
+        log_pfn_register(p, "P", log_pid_tid, 0);
         log_pfn_register(p, "H", log_request_protocol, 0);
         log_pfn_register(p, "m", log_request_method, 0);
         log_pfn_register(p, "q", log_request_query, 0);