Mercurial > hg > nginx
comparison src/http/modules/ngx_http_log_module.c @ 4905:5cad4cb1f484 stable-1.2
Merge of r4886, r4887, r4894: log variables generalization:
*) Log: $apache_bytes_sent removed. It was renamed to $body_bytes_sent
in nginx 0.3.10 and the old name is deprecated since then.
*) Variable $bytes_sent. It replicates variable $bytes_sent as previously
available in log module only. Patch by Benjamin Grössing (with minor
changes).
*) Variables $connection and $connection_requests. Log module
counterparts are removed as they aren't used often and there is no
need to preserve them for efficiency.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Tue, 13 Nov 2012 10:45:23 +0000 |
parents | 29928279ec9f |
children | 004af18ddb86 |
comparison
equal
deleted
inserted
replaced
4904:c3b276283e4a | 4905:5cad4cb1f484 |
---|---|
76 static void ngx_http_log_write(ngx_http_request_t *r, ngx_http_log_t *log, | 76 static void ngx_http_log_write(ngx_http_request_t *r, ngx_http_log_t *log, |
77 u_char *buf, size_t len); | 77 u_char *buf, size_t len); |
78 static ssize_t ngx_http_log_script_write(ngx_http_request_t *r, | 78 static ssize_t ngx_http_log_script_write(ngx_http_request_t *r, |
79 ngx_http_log_script_t *script, u_char **name, u_char *buf, size_t len); | 79 ngx_http_log_script_t *script, u_char **name, u_char *buf, size_t len); |
80 | 80 |
81 static u_char *ngx_http_log_connection(ngx_http_request_t *r, u_char *buf, | |
82 ngx_http_log_op_t *op); | |
83 static u_char *ngx_http_log_connection_requests(ngx_http_request_t *r, | |
84 u_char *buf, ngx_http_log_op_t *op); | |
85 static u_char *ngx_http_log_pipe(ngx_http_request_t *r, u_char *buf, | 81 static u_char *ngx_http_log_pipe(ngx_http_request_t *r, u_char *buf, |
86 ngx_http_log_op_t *op); | 82 ngx_http_log_op_t *op); |
87 static u_char *ngx_http_log_time(ngx_http_request_t *r, u_char *buf, | 83 static u_char *ngx_http_log_time(ngx_http_request_t *r, u_char *buf, |
88 ngx_http_log_op_t *op); | 84 ngx_http_log_op_t *op); |
89 static u_char *ngx_http_log_iso8601(ngx_http_request_t *r, u_char *buf, | 85 static u_char *ngx_http_log_iso8601(ngx_http_request_t *r, u_char *buf, |
192 "\"$request\" $status $body_bytes_sent " | 188 "\"$request\" $status $body_bytes_sent " |
193 "\"$http_referer\" \"$http_user_agent\""); | 189 "\"$http_referer\" \"$http_user_agent\""); |
194 | 190 |
195 | 191 |
196 static ngx_http_log_var_t ngx_http_log_vars[] = { | 192 static ngx_http_log_var_t ngx_http_log_vars[] = { |
197 { ngx_string("connection"), NGX_ATOMIC_T_LEN, ngx_http_log_connection }, | |
198 { ngx_string("connection_requests"), NGX_INT_T_LEN, | |
199 ngx_http_log_connection_requests }, | |
200 { ngx_string("pipe"), 1, ngx_http_log_pipe }, | 193 { ngx_string("pipe"), 1, ngx_http_log_pipe }, |
201 { ngx_string("time_local"), sizeof("28/Sep/1970:12:00:00 +0600") - 1, | 194 { ngx_string("time_local"), sizeof("28/Sep/1970:12:00:00 +0600") - 1, |
202 ngx_http_log_time }, | 195 ngx_http_log_time }, |
203 { ngx_string("time_iso8601"), sizeof("1970-09-28T12:00:00+06:00") - 1, | 196 { ngx_string("time_iso8601"), sizeof("1970-09-28T12:00:00+06:00") - 1, |
204 ngx_http_log_iso8601 }, | 197 ngx_http_log_iso8601 }, |
207 ngx_http_log_request_time }, | 200 ngx_http_log_request_time }, |
208 { ngx_string("status"), NGX_INT_T_LEN, ngx_http_log_status }, | 201 { ngx_string("status"), NGX_INT_T_LEN, ngx_http_log_status }, |
209 { ngx_string("bytes_sent"), NGX_OFF_T_LEN, ngx_http_log_bytes_sent }, | 202 { ngx_string("bytes_sent"), NGX_OFF_T_LEN, ngx_http_log_bytes_sent }, |
210 { ngx_string("body_bytes_sent"), NGX_OFF_T_LEN, | 203 { ngx_string("body_bytes_sent"), NGX_OFF_T_LEN, |
211 ngx_http_log_body_bytes_sent }, | 204 ngx_http_log_body_bytes_sent }, |
212 { ngx_string("apache_bytes_sent"), NGX_OFF_T_LEN, | |
213 ngx_http_log_body_bytes_sent }, | |
214 { ngx_string("request_length"), NGX_SIZE_T_LEN, | 205 { ngx_string("request_length"), NGX_SIZE_T_LEN, |
215 ngx_http_log_request_length }, | 206 ngx_http_log_request_length }, |
216 | 207 |
217 { ngx_null_string, 0, NULL } | 208 { ngx_null_string, 0, NULL } |
218 }; | 209 }; |
496 static u_char * | 487 static u_char * |
497 ngx_http_log_copy_long(ngx_http_request_t *r, u_char *buf, | 488 ngx_http_log_copy_long(ngx_http_request_t *r, u_char *buf, |
498 ngx_http_log_op_t *op) | 489 ngx_http_log_op_t *op) |
499 { | 490 { |
500 return ngx_cpymem(buf, (u_char *) op->data, op->len); | 491 return ngx_cpymem(buf, (u_char *) op->data, op->len); |
501 } | |
502 | |
503 | |
504 static u_char * | |
505 ngx_http_log_connection(ngx_http_request_t *r, u_char *buf, | |
506 ngx_http_log_op_t *op) | |
507 { | |
508 return ngx_sprintf(buf, "%uA", r->connection->number); | |
509 } | |
510 | |
511 | |
512 static u_char * | |
513 ngx_http_log_connection_requests(ngx_http_request_t *r, u_char *buf, | |
514 ngx_http_log_op_t *op) | |
515 { | |
516 return ngx_sprintf(buf, "%ui", r->connection->requests); | |
517 } | 492 } |
518 | 493 |
519 | 494 |
520 static u_char * | 495 static u_char * |
521 ngx_http_log_pipe(ngx_http_request_t *r, u_char *buf, ngx_http_log_op_t *op) | 496 ngx_http_log_pipe(ngx_http_request_t *r, u_char *buf, ngx_http_log_op_t *op) |
1141 | 1116 |
1142 if (var.len == 0) { | 1117 if (var.len == 0) { |
1143 goto invalid; | 1118 goto invalid; |
1144 } | 1119 } |
1145 | 1120 |
1146 if (ngx_strncmp(var.data, "apache_bytes_sent", 17) == 0) { | |
1147 ngx_conf_log_error(NGX_LOG_WARN, cf, 0, | |
1148 "use \"$body_bytes_sent\" instead of " | |
1149 "\"$apache_bytes_sent\""); | |
1150 } | |
1151 | |
1152 for (v = ngx_http_log_vars; v->name.len; v++) { | 1121 for (v = ngx_http_log_vars; v->name.len; v++) { |
1153 | 1122 |
1154 if (v->name.len == var.len | 1123 if (v->name.len == var.len |
1155 && ngx_strncmp(v->name.data, var.data, var.len) == 0) | 1124 && ngx_strncmp(v->name.data, var.data, var.len) == 0) |
1156 { | 1125 { |