From: Jeff Trawick Date: Thu, 21 May 2015 19:20:44 +0000 (+0000) Subject: Follow-up to r1680895: X-Git-Tag: 2.5.0-alpha~3140 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=08a4db9f1afe1ca67236e90c950525f4108c1db7;p=apache Follow-up to r1680895: Let %T be the format character which accepts time resolution arguments. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1680942 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/docs/manual/mod/mod_log_config.xml b/docs/manual/mod/mod_log_config.xml index 8cd45b67e1..d6ec402a7a 100644 --- a/docs/manual/mod/mod_log_config.xml +++ b/docs/manual/mod/mod_log_config.xml @@ -95,15 +95,6 @@ %D The time taken to serve the request, in microseconds. - %{UNIT}D - The time taken to serve the request, in a time unit given by - UNIT. Valid units are ms for milliseconds, - us for microseconds and s for seconds. - Using us gives the same result as %D - without any format, using s gives teh same result - as %T. Combining %D with a unit is - available in 2.4.13 and later. - %{VARNAME}e The contents of the environment variable VARNAME. @@ -225,6 +216,15 @@ %T The time taken to serve the request, in seconds. + %{UNIT}T + The time taken to serve the request, in a time unit given by + UNIT. Valid units are ms for milliseconds, + us for microseconds, and s for seconds. + Using s gives the same result as %T + without any format; using us gives the same result + as %D. Combining %T with a unit is + available in 2.4.13 and later. + %u Remote user if the request was authenticated. May be bogus if return status (%s) is 401 (unauthorized). diff --git a/modules/loggers/mod_log_config.c b/modules/loggers/mod_log_config.c index fd3f5f6670..871fa5dd3d 100644 --- a/modules/loggers/mod_log_config.c +++ b/modules/loggers/mod_log_config.c @@ -101,10 +101,10 @@ * %...{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. + * %...{s}T: the time taken to serve the request, in seconds, same as %T. + * %...{us}T: the time taken to serve the request, in micro seconds, same as %D. + * %...{ms}T: the time taken to serve the request, in milliseconds. * %...D: the time taken to serve the request, in micro seconds. - * %...{s}D: the time taken to serve the request, in seconds, same as %T. - * %...{us}D: the time taken to serve the request, in micro seconds, same as %D. - * %...{ms}D: the time taken to serve the request, in milliseconds. * %...u: remote user (from auth; may be bogus if return status (%s) is 401) * %...U: the URL path requested. * %...v: the configured name of the server (i.e. which virtual host?) @@ -799,22 +799,22 @@ static const char *log_request_time(request_rec *r, char *a) } } -static const char *log_request_duration(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_sec(duration)); +static const char *log_request_duration_microseconds(request_rec *r, char *a) +{ + return apr_psprintf(r->pool, "%" APR_TIME_T_FMT, + (get_request_end_time(r) - r->request_time)); } static const char *log_request_duration_scaled(request_rec *r, char *a) { apr_time_t duration = get_request_end_time(r) - r->request_time; - if (*a == '\0' || !strcasecmp(a, "us")) { + if (*a == '\0' || !strcasecmp(a, "s")) { + duration = apr_time_sec(duration); } else if (!strcasecmp(a, "ms")) { duration = apr_time_as_msec(duration); } - else if (!strcasecmp(a, "s")) { - duration = apr_time_sec(duration); + else if (!strcasecmp(a, "us")) { } else { /* bogus format */ @@ -1851,8 +1851,8 @@ static int log_pre_config(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp) log_pfn_register(p, "C", log_cookie, 0); 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_scaled, 1); - log_pfn_register(p, "T", log_request_duration, 1); + log_pfn_register(p, "D", log_request_duration_microseconds, 1); + log_pfn_register(p, "T", log_request_duration_scaled, 1); log_pfn_register(p, "U", log_request_uri, 1); log_pfn_register(p, "s", log_status, 1); log_pfn_register(p, "R", log_handler, 1);