]> granicus.if.org Git - apache/commitdiff
mod_log_config: Add %M format to output request duration in milliseconds.
authorBen Reser <breser@apache.org>
Thu, 23 Apr 2015 03:12:30 +0000 (03:12 +0000)
committerBen Reser <breser@apache.org>
Thu, 23 Apr 2015 03:12:30 +0000 (03:12 +0000)
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1675533 13f79535-47bb-0310-9956-ffa450edef68

docs/manual/mod/mod_log_config.xml
modules/loggers/mod_log_config.c

index 7a6d4c2cb38a6ec96b6d829f5f20cb83b07a942e..7b27026fe1e582c1e0b03490f74b7c824ec294af 100644 (file)
     <tr><td><code>%m</code></td>
         <td>The request method.</td></tr>
 
+    <tr><td><code>%M</code></td>
+        <td>The time taken to serve the request, in milliseconds.</td></tr>
+
     <tr><td><code>%{<var>VARNAME</var>}n</code></td>
         <td>The contents of note <var>VARNAME</var> from another
         module.</td></tr>
index 6bc7cd418198febd71e13a000ef9b736f163ad74..54e4be9a2c28a6cfc20c2a09e40a170f4c02dc8b 100644 (file)
  * %...{format}t:  The time, in the form given by format, which should
  *                 be in strftime(3) format.
  * %...T:  the time taken to serve the request, in seconds.
+ * %...M:  the time taken to serve the request, in milliseconds
  * %...D:  the time taken to serve the request, in micro seconds.
  * %...u:  remote user (from auth; may be bogus if return status (%s) is 401)
  * %...U:  the URL path requested.
@@ -802,6 +803,13 @@ static const char *log_request_duration(request_rec *r, char *a)
     return apr_psprintf(r->pool, "%" APR_TIME_T_FMT, apr_time_sec(duration));
 }
 
+static const char *log_request_duration_milliseconds(request_rec *r, char *a)
+{
+    apr_time_t duration = get_request_end_time(r) - r->request_time;
+    return apr_psprintf(r->pool, "%" APR_TIME_T_FMT, apr_time_as_msec(duration));
+}
+
+
 static const char *log_request_duration_microseconds(request_rec *r, char *a)
 {
     return apr_psprintf(r->pool, "%" APR_TIME_T_FMT,
@@ -1837,6 +1845,7 @@ static int log_pre_config(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp)
         log_pfn_register(p, "k", log_requests_on_connection, 0);
         log_pfn_register(p, "r", log_request_line, 1);
         log_pfn_register(p, "D", log_request_duration_microseconds, 1);
+        log_pfn_register(p, "M", log_request_duration_milliseconds, 1);
         log_pfn_register(p, "T", log_request_duration, 1);
         log_pfn_register(p, "U", log_request_uri, 1);
         log_pfn_register(p, "s", log_status, 1);