diff options
author | Ben Reser <breser@apache.org> | 2015-04-23 05:12:30 +0200 |
---|---|---|
committer | Ben Reser <breser@apache.org> | 2015-04-23 05:12:30 +0200 |
commit | ca8f9495c7350e1b214d3083ca0dbf8ab0545f41 (patch) | |
tree | 0c6ff7d548760294c4e6b0118803cf427827af71 | |
parent | Generated doc changes (diff) | |
download | apache2-ca8f9495c7350e1b214d3083ca0dbf8ab0545f41.tar.xz apache2-ca8f9495c7350e1b214d3083ca0dbf8ab0545f41.zip |
mod_log_config: Add %M format to output request duration in milliseconds.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1675533 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | docs/manual/mod/mod_log_config.xml | 3 | ||||
-rw-r--r-- | modules/loggers/mod_log_config.c | 9 |
2 files changed, 12 insertions, 0 deletions
diff --git a/docs/manual/mod/mod_log_config.xml b/docs/manual/mod/mod_log_config.xml index 7a6d4c2cb3..7b27026fe1 100644 --- a/docs/manual/mod/mod_log_config.xml +++ b/docs/manual/mod/mod_log_config.xml @@ -146,6 +146,9 @@ <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> diff --git a/modules/loggers/mod_log_config.c b/modules/loggers/mod_log_config.c index 6bc7cd4181..54e4be9a2c 100644 --- a/modules/loggers/mod_log_config.c +++ b/modules/loggers/mod_log_config.c @@ -101,6 +101,7 @@ * %...{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); |