From 82c9e7d8542468d3858662ed75490966f03108ad Mon Sep 17 00:00:00 2001 From: Jim Jagielski Date: Fri, 1 May 2015 17:03:35 +0000 Subject: [PATCH] Merge r1675533 from trunk: mod_log_config: Add %M format to output request duration in milliseconds. Submitted by: breser Reviewed/backported by: jim git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1677187 13f79535-47bb-0310-9956-ffa450edef68 --- STATUS | 5 ----- docs/manual/mod/mod_log_config.xml | 3 +++ modules/loggers/mod_log_config.c | 9 +++++++++ 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/STATUS b/STATUS index 730c1e4cb0..14a9bb5bc4 100644 --- a/STATUS +++ b/STATUS @@ -105,11 +105,6 @@ RELEASE SHOWSTOPPERS: PATCHES ACCEPTED TO BACKPORT FROM TRUNK: [ start all new proposals below, under PATCHES PROPOSED. ] - *) mod_log_config: Add new format flag for requestion duration in milliseconds - trunk patch: http://svn.apache.org/r1675533 - 2.4.x patch: trunk works (modulo CHANGES) - +1: breser, druggeri, jim - PATCHES PROPOSED TO BACKPORT FROM TRUNK: diff --git a/docs/manual/mod/mod_log_config.xml b/docs/manual/mod/mod_log_config.xml index 711d597fb6..072ac766af 100644 --- a/docs/manual/mod/mod_log_config.xml +++ b/docs/manual/mod/mod_log_config.xml @@ -146,6 +146,9 @@ %m The request method. + %M + The time taken to serve the request, in milliseconds. + %{VARNAME}n The contents of note VARNAME from another module. diff --git a/modules/loggers/mod_log_config.c b/modules/loggers/mod_log_config.c index c1b0e1ba67..db3d60bb02 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. @@ -771,6 +772,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, @@ -1710,6 +1718,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); -- 2.40.0