comparison 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
comparison
equal deleted inserted replaced
1178:a77f6980de50 1179:6e2216ad2c87
168 { ngx_string("connection"), NGX_ATOMIC_T_LEN, ngx_http_log_connection }, 168 { ngx_string("connection"), NGX_ATOMIC_T_LEN, ngx_http_log_connection },
169 { ngx_string("pipe"), 1, ngx_http_log_pipe }, 169 { ngx_string("pipe"), 1, ngx_http_log_pipe },
170 { ngx_string("time_local"), sizeof("28/Sep/1970:12:00:00 +0600") - 1, 170 { ngx_string("time_local"), sizeof("28/Sep/1970:12:00:00 +0600") - 1,
171 ngx_http_log_time }, 171 ngx_http_log_time },
172 { ngx_string("msec"), NGX_TIME_T_LEN + 4, ngx_http_log_msec }, 172 { ngx_string("msec"), NGX_TIME_T_LEN + 4, ngx_http_log_msec },
173 { ngx_string("request_time"), NGX_TIME_T_LEN, ngx_http_log_request_time }, 173 { ngx_string("request_time"), NGX_TIME_T_LEN + 4,
174 ngx_http_log_request_time },
174 { ngx_string("status"), 3, ngx_http_log_status }, 175 { ngx_string("status"), 3, ngx_http_log_status },
175 { ngx_string("bytes_sent"), NGX_OFF_T_LEN, ngx_http_log_bytes_sent }, 176 { ngx_string("bytes_sent"), NGX_OFF_T_LEN, ngx_http_log_bytes_sent },
176 { ngx_string("body_bytes_sent"), NGX_OFF_T_LEN, 177 { ngx_string("body_bytes_sent"), NGX_OFF_T_LEN,
177 ngx_http_log_body_bytes_sent }, 178 ngx_http_log_body_bytes_sent },
178 { ngx_string("apache_bytes_sent"), NGX_OFF_T_LEN, 179 { ngx_string("apache_bytes_sent"), NGX_OFF_T_LEN,
392 393
393 static u_char * 394 static u_char *
394 ngx_http_log_request_time(ngx_http_request_t *r, u_char *buf, 395 ngx_http_log_request_time(ngx_http_request_t *r, u_char *buf,
395 ngx_http_log_op_t *op) 396 ngx_http_log_op_t *op)
396 { 397 {
397 time_t elapsed; 398 ngx_time_t *tp;
398 399 ngx_msec_int_t ms;
399 elapsed = ngx_time() - r->start_time; 400
400 401 tp = ngx_timeofday();
401 return ngx_sprintf(buf, "%T", elapsed); 402
403 ms = (tp->sec - r->start_sec) * 1000 + (tp->msec - r->start_msec);
404 ms = (ms >= 0) ? ms : 0;
405
406 return ngx_sprintf(buf, "%T.%03M", ms / 1000, ms % 1000);
402 } 407 }
403 408
404 409
405 static u_char * 410 static u_char *
406 ngx_http_log_status(ngx_http_request_t *r, u_char *buf, ngx_http_log_op_t *op) 411 ngx_http_log_status(ngx_http_request_t *r, u_char *buf, ngx_http_log_op_t *op)