Mercurial > hg > nginx-ranges
comparison src/http/modules/ngx_http_log_module.c @ 635:e67b227c8dbb default tip
Merge with current.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Mon, 25 Apr 2011 04:07:55 +0400 |
parents | 8214eaef3530 |
children |
comparison
equal
deleted
inserted
replaced
578:f3a9e57d2e17 | 635:e67b227c8dbb |
---|---|
80 static u_char *ngx_http_log_connection(ngx_http_request_t *r, u_char *buf, | 80 static u_char *ngx_http_log_connection(ngx_http_request_t *r, u_char *buf, |
81 ngx_http_log_op_t *op); | 81 ngx_http_log_op_t *op); |
82 static u_char *ngx_http_log_pipe(ngx_http_request_t *r, u_char *buf, | 82 static u_char *ngx_http_log_pipe(ngx_http_request_t *r, u_char *buf, |
83 ngx_http_log_op_t *op); | 83 ngx_http_log_op_t *op); |
84 static u_char *ngx_http_log_time(ngx_http_request_t *r, u_char *buf, | 84 static u_char *ngx_http_log_time(ngx_http_request_t *r, u_char *buf, |
85 ngx_http_log_op_t *op); | |
86 static u_char *ngx_http_log_iso8601(ngx_http_request_t *r, u_char *buf, | |
85 ngx_http_log_op_t *op); | 87 ngx_http_log_op_t *op); |
86 static u_char *ngx_http_log_msec(ngx_http_request_t *r, u_char *buf, | 88 static u_char *ngx_http_log_msec(ngx_http_request_t *r, u_char *buf, |
87 ngx_http_log_op_t *op); | 89 ngx_http_log_op_t *op); |
88 static u_char *ngx_http_log_request_time(ngx_http_request_t *r, u_char *buf, | 90 static u_char *ngx_http_log_request_time(ngx_http_request_t *r, u_char *buf, |
89 ngx_http_log_op_t *op); | 91 ngx_http_log_op_t *op); |
191 static ngx_http_log_var_t ngx_http_log_vars[] = { | 193 static ngx_http_log_var_t ngx_http_log_vars[] = { |
192 { ngx_string("connection"), NGX_ATOMIC_T_LEN, ngx_http_log_connection }, | 194 { ngx_string("connection"), NGX_ATOMIC_T_LEN, ngx_http_log_connection }, |
193 { ngx_string("pipe"), 1, ngx_http_log_pipe }, | 195 { ngx_string("pipe"), 1, ngx_http_log_pipe }, |
194 { ngx_string("time_local"), sizeof("28/Sep/1970:12:00:00 +0600") - 1, | 196 { ngx_string("time_local"), sizeof("28/Sep/1970:12:00:00 +0600") - 1, |
195 ngx_http_log_time }, | 197 ngx_http_log_time }, |
198 { ngx_string("time_iso8601"), sizeof("1970-09-28T12:00:00+06:00") - 1, | |
199 ngx_http_log_iso8601 }, | |
196 { ngx_string("msec"), NGX_TIME_T_LEN + 4, ngx_http_log_msec }, | 200 { ngx_string("msec"), NGX_TIME_T_LEN + 4, ngx_http_log_msec }, |
197 { ngx_string("request_time"), NGX_TIME_T_LEN + 4, | 201 { ngx_string("request_time"), NGX_TIME_T_LEN + 4, |
198 ngx_http_log_request_time }, | 202 ngx_http_log_request_time }, |
199 { ngx_string("status"), 3, ngx_http_log_status }, | 203 { ngx_string("status"), 3, ngx_http_log_status }, |
200 { ngx_string("bytes_sent"), NGX_OFF_T_LEN, ngx_http_log_bytes_sent }, | 204 { ngx_string("bytes_sent"), NGX_OFF_T_LEN, ngx_http_log_bytes_sent }, |
508 { | 512 { |
509 return ngx_cpymem(buf, ngx_cached_http_log_time.data, | 513 return ngx_cpymem(buf, ngx_cached_http_log_time.data, |
510 ngx_cached_http_log_time.len); | 514 ngx_cached_http_log_time.len); |
511 } | 515 } |
512 | 516 |
517 static u_char * | |
518 ngx_http_log_iso8601(ngx_http_request_t *r, u_char *buf, ngx_http_log_op_t *op) | |
519 { | |
520 return ngx_cpymem(buf, ngx_cached_http_log_iso8601.data, | |
521 ngx_cached_http_log_iso8601.len); | |
522 } | |
513 | 523 |
514 static u_char * | 524 static u_char * |
515 ngx_http_log_msec(ngx_http_request_t *r, u_char *buf, ngx_http_log_op_t *op) | 525 ngx_http_log_msec(ngx_http_request_t *r, u_char *buf, ngx_http_log_op_t *op) |
516 { | 526 { |
517 ngx_time_t *tp; | 527 ngx_time_t *tp; |
531 | 541 |
532 tp = ngx_timeofday(); | 542 tp = ngx_timeofday(); |
533 | 543 |
534 ms = (ngx_msec_int_t) | 544 ms = (ngx_msec_int_t) |
535 ((tp->sec - r->start_sec) * 1000 + (tp->msec - r->start_msec)); | 545 ((tp->sec - r->start_sec) * 1000 + (tp->msec - r->start_msec)); |
536 ms = (ms >= 0) ? ms : 0; | 546 ms = ngx_max(ms, 0); |
537 | 547 |
538 return ngx_sprintf(buf, "%T.%03M", ms / 1000, ms % 1000); | 548 return ngx_sprintf(buf, "%T.%03M", ms / 1000, ms % 1000); |
539 } | 549 } |
540 | 550 |
541 | 551 |
745 fmt = ngx_array_push(&conf->formats); | 755 fmt = ngx_array_push(&conf->formats); |
746 if (fmt == NULL) { | 756 if (fmt == NULL) { |
747 return NULL; | 757 return NULL; |
748 } | 758 } |
749 | 759 |
750 fmt->name.len = sizeof("combined") - 1; | 760 ngx_str_set(&fmt->name, "combined"); |
751 fmt->name.data = (u_char *) "combined"; | |
752 | 761 |
753 fmt->flushes = NULL; | 762 fmt->flushes = NULL; |
754 | 763 |
755 fmt->ops = ngx_array_create(cf->pool, 16, sizeof(ngx_http_log_op_t)); | 764 fmt->ops = ngx_array_create(cf->pool, 16, sizeof(ngx_http_log_op_t)); |
756 if (fmt->ops == NULL) { | 765 if (fmt->ops == NULL) { |
920 if (ngx_strcmp(name.data, "combined") == 0) { | 929 if (ngx_strcmp(name.data, "combined") == 0) { |
921 lmcf->combined_used = 1; | 930 lmcf->combined_used = 1; |
922 } | 931 } |
923 | 932 |
924 } else { | 933 } else { |
925 name.len = sizeof("combined") - 1; | 934 ngx_str_set(&name, "combined"); |
926 name.data = (u_char *) "combined"; | |
927 lmcf->combined_used = 1; | 935 lmcf->combined_used = 1; |
928 } | 936 } |
929 | 937 |
930 fmt = lmcf->formats.elts; | 938 fmt = lmcf->formats.elts; |
931 for (i = 0; i < lmcf->formats.nelts; i++) { | 939 for (i = 0; i < lmcf->formats.nelts; i++) { |