Mercurial > hg > nginx
diff src/http/modules/ngx_http_log_module.c @ 1179:6e2216ad2c87
$request_time has millisecond precision
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Sat, 21 Apr 2007 07:50:19 +0000 |
parents | 6002e0253221 |
children | 2b3e6aede7da |
line wrap: on
line diff
--- a/src/http/modules/ngx_http_log_module.c Sat Apr 21 07:43:23 2007 +0000 +++ b/src/http/modules/ngx_http_log_module.c Sat Apr 21 07:50:19 2007 +0000 @@ -170,7 +170,8 @@ { ngx_string("time_local"), sizeof("28/Sep/1970:12:00:00 +0600") - 1, ngx_http_log_time }, { ngx_string("msec"), NGX_TIME_T_LEN + 4, ngx_http_log_msec }, - { ngx_string("request_time"), NGX_TIME_T_LEN, ngx_http_log_request_time }, + { ngx_string("request_time"), NGX_TIME_T_LEN + 4, + ngx_http_log_request_time }, { ngx_string("status"), 3, ngx_http_log_status }, { ngx_string("bytes_sent"), NGX_OFF_T_LEN, ngx_http_log_bytes_sent }, { ngx_string("body_bytes_sent"), NGX_OFF_T_LEN, @@ -394,11 +395,15 @@ ngx_http_log_request_time(ngx_http_request_t *r, u_char *buf, ngx_http_log_op_t *op) { - time_t elapsed; + ngx_time_t *tp; + ngx_msec_int_t ms; + + tp = ngx_timeofday(); - elapsed = ngx_time() - r->start_time; + ms = (tp->sec - r->start_sec) * 1000 + (tp->msec - r->start_msec); + ms = (ms >= 0) ? ms : 0; - return ngx_sprintf(buf, "%T", elapsed); + return ngx_sprintf(buf, "%T.%03M", ms / 1000, ms % 1000); }