Mercurial > hg > nginx-quic
annotate src/http/modules/ngx_http_log_module.c @ 612:182bfe05e2c3
release-0.3.27 tag
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Wed, 08 Feb 2006 15:33:12 +0000 |
parents | 326634fb9d47 |
children | f971949ffb58 |
rev | line source |
---|---|
441
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
427
diff
changeset
|
1 |
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
427
diff
changeset
|
2 /* |
444
42d11f017717
nginx-0.1.0-2004-09-29-20:00:49 import; remove years from copyright
Igor Sysoev <igor@sysoev.ru>
parents:
441
diff
changeset
|
3 * Copyright (C) Igor Sysoev |
441
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
427
diff
changeset
|
4 */ |
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
427
diff
changeset
|
5 |
26
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
6 |
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
7 #include <ngx_config.h> |
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
8 #include <ngx_core.h> |
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
9 #include <ngx_http.h> |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
10 #include <nginx.h> |
26
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
11 |
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
12 |
573 | 13 |
14 typedef struct { | |
15 ngx_str_t name; | |
16 ngx_array_t *ops; /* array of ngx_http_log_op_t */ | |
17 } ngx_http_log_fmt_t; | |
18 | |
19 typedef struct { | |
20 ngx_array_t formats; /* array of ngx_http_log_fmt_t */ | |
21 ngx_uint_t combined_used; /* unsigned combined_used:1 */ | |
22 } ngx_http_log_main_conf_t; | |
23 | |
24 typedef struct { | |
25 ngx_open_file_t *file; | |
26 ngx_array_t *ops; /* array of ngx_http_log_op_t */ | |
27 } ngx_http_log_t; | |
28 | |
29 typedef struct { | |
30 ngx_array_t *logs; /* array of ngx_http_log_t */ | |
31 ngx_uint_t off; /* unsigned off:1 */ | |
32 } ngx_http_log_loc_conf_t; | |
33 | |
34 | |
35 typedef struct { | |
36 ngx_str_t name; | |
37 size_t len; | |
38 ngx_http_log_op_run_pt run; | |
39 } ngx_http_log_var_t; | |
40 | |
41 | |
290
87e73f067470
nginx-0.0.2-2004-03-16-10:10:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
282
diff
changeset
|
42 static u_char *ngx_http_log_addr(ngx_http_request_t *r, u_char *buf, |
497 | 43 ngx_http_log_op_t *op); |
290
87e73f067470
nginx-0.0.2-2004-03-16-10:10:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
282
diff
changeset
|
44 static u_char *ngx_http_log_connection(ngx_http_request_t *r, u_char *buf, |
497 | 45 ngx_http_log_op_t *op); |
290
87e73f067470
nginx-0.0.2-2004-03-16-10:10:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
282
diff
changeset
|
46 static u_char *ngx_http_log_pipe(ngx_http_request_t *r, u_char *buf, |
497 | 47 ngx_http_log_op_t *op); |
290
87e73f067470
nginx-0.0.2-2004-03-16-10:10:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
282
diff
changeset
|
48 static u_char *ngx_http_log_time(ngx_http_request_t *r, u_char *buf, |
497 | 49 ngx_http_log_op_t *op); |
409
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
393
diff
changeset
|
50 static u_char *ngx_http_log_msec(ngx_http_request_t *r, u_char *buf, |
497 | 51 ngx_http_log_op_t *op); |
52 static u_char *ngx_http_log_request_time(ngx_http_request_t *r, u_char *buf, | |
53 ngx_http_log_op_t *op); | |
290
87e73f067470
nginx-0.0.2-2004-03-16-10:10:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
282
diff
changeset
|
54 static u_char *ngx_http_log_status(ngx_http_request_t *r, u_char *buf, |
497 | 55 ngx_http_log_op_t *op); |
573 | 56 static u_char *ngx_http_log_bytes_sent(ngx_http_request_t *r, u_char *buf, |
497 | 57 ngx_http_log_op_t *op); |
577 | 58 static u_char *ngx_http_log_body_bytes_sent(ngx_http_request_t *r, |
573 | 59 u_char *buf, ngx_http_log_op_t *op); |
475 | 60 static u_char *ngx_http_log_request_length(ngx_http_request_t *r, u_char *buf, |
497 | 61 ngx_http_log_op_t *op); |
479 | 62 |
63 static size_t ngx_http_log_request_getlen(ngx_http_request_t *r, | |
497 | 64 uintptr_t data); |
479 | 65 static u_char *ngx_http_log_request(ngx_http_request_t *r, u_char *buf, |
497 | 66 ngx_http_log_op_t *op); |
479 | 67 |
501 | 68 static ngx_int_t ngx_http_log_header_in_compile(ngx_conf_t *cf, |
69 ngx_http_log_op_t *op, ngx_str_t *value); | |
479 | 70 static size_t ngx_http_log_header_in_getlen(ngx_http_request_t *r, |
497 | 71 uintptr_t data); |
290
87e73f067470
nginx-0.0.2-2004-03-16-10:10:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
282
diff
changeset
|
72 static u_char *ngx_http_log_header_in(ngx_http_request_t *r, u_char *buf, |
497 | 73 ngx_http_log_op_t *op); |
479 | 74 static size_t ngx_http_log_unknown_header_in_getlen(ngx_http_request_t *r, |
497 | 75 uintptr_t data); |
479 | 76 static u_char *ngx_http_log_unknown_header_in(ngx_http_request_t *r, |
497 | 77 u_char *buf, ngx_http_log_op_t *op); |
479 | 78 |
501 | 79 static ngx_int_t ngx_http_log_header_out_compile(ngx_conf_t *cf, |
80 ngx_http_log_op_t *op, ngx_str_t *value); | |
479 | 81 static size_t ngx_http_log_header_out_getlen(ngx_http_request_t *r, |
497 | 82 uintptr_t data); |
479 | 83 static u_char *ngx_http_log_header_out(ngx_http_request_t *r, u_char *buf, |
497 | 84 ngx_http_log_op_t *op); |
479 | 85 static size_t ngx_http_log_unknown_header_out_getlen(ngx_http_request_t *r, |
497 | 86 uintptr_t data); |
479 | 87 static u_char *ngx_http_log_unknown_header_out(ngx_http_request_t *r, |
497 | 88 u_char *buf, ngx_http_log_op_t *op); |
479 | 89 |
290
87e73f067470
nginx-0.0.2-2004-03-16-10:10:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
282
diff
changeset
|
90 static u_char *ngx_http_log_connection_header_out(ngx_http_request_t *r, |
497 | 91 u_char *buf, ngx_http_log_op_t *op); |
290
87e73f067470
nginx-0.0.2-2004-03-16-10:10:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
282
diff
changeset
|
92 static u_char *ngx_http_log_transfer_encoding_header_out(ngx_http_request_t *r, |
497 | 93 u_char *buf, ngx_http_log_op_t *op); |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
94 |
479 | 95 static ngx_table_elt_t *ngx_http_log_unknown_header(ngx_list_t *headers, |
497 | 96 ngx_str_t *value); |
479 | 97 |
501 | 98 static ngx_int_t ngx_http_log_variable_compile(ngx_conf_t *cf, |
99 ngx_http_log_op_t *op, ngx_str_t *value); | |
100 static size_t ngx_http_log_variable_getlen(ngx_http_request_t *r, | |
101 uintptr_t data); | |
102 static u_char *ngx_http_log_variable(ngx_http_request_t *r, u_char *buf, | |
103 ngx_http_log_op_t *op); | |
104 | |
105 | |
479 | 106 static ngx_int_t ngx_http_log_set_formats(ngx_conf_t *cf); |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
107 static void *ngx_http_log_create_main_conf(ngx_conf_t *cf); |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
108 static void *ngx_http_log_create_loc_conf(ngx_conf_t *cf); |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
109 static char *ngx_http_log_merge_loc_conf(ngx_conf_t *cf, void *parent, |
497 | 110 void *child); |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
111 static char *ngx_http_log_set_log(ngx_conf_t *cf, ngx_command_t *cmd, |
497 | 112 void *conf); |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
113 static char *ngx_http_log_set_format(ngx_conf_t *cf, ngx_command_t *cmd, |
497 | 114 void *conf); |
573 | 115 static char *ngx_http_log_compile_format(ngx_conf_t *cf, |
116 ngx_array_t *ops, ngx_array_t *args, ngx_uint_t s); | |
117 static ngx_int_t ngx_http_log_init(ngx_conf_t *cf); | |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
118 |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
119 |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
120 static ngx_command_t ngx_http_log_commands[] = { |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
121 |
497 | 122 { ngx_string("log_format"), |
123 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_2MORE, | |
124 ngx_http_log_set_format, | |
125 NGX_HTTP_MAIN_CONF_OFFSET, | |
126 0, | |
127 NULL }, | |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
128 |
497 | 129 { ngx_string("access_log"), |
571 | 130 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE123, |
497 | 131 ngx_http_log_set_log, |
132 NGX_HTTP_LOC_CONF_OFFSET, | |
133 0, | |
134 NULL }, | |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
135 |
497 | 136 ngx_null_command |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
137 }; |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
138 |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
139 |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
140 ngx_http_module_t ngx_http_log_module_ctx = { |
509 | 141 ngx_http_log_set_formats, /* preconfiguration */ |
573 | 142 ngx_http_log_init, /* postconfiguration */ |
177
4db54fdbcbe7
nginx-0.0.1-2003-11-10-20:17:31 import
Igor Sysoev <igor@sysoev.ru>
parents:
176
diff
changeset
|
143 |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
144 ngx_http_log_create_main_conf, /* create main configuration */ |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
145 NULL, /* init main configuration */ |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
146 |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
147 NULL, /* create server configuration */ |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
148 NULL, /* merge server configuration */ |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
149 |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
150 ngx_http_log_create_loc_conf, /* create location configration */ |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
151 ngx_http_log_merge_loc_conf /* merge location configration */ |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
152 }; |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
153 |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
154 |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
155 ngx_module_t ngx_http_log_module = { |
509 | 156 NGX_MODULE_V1, |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
157 &ngx_http_log_module_ctx, /* module context */ |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
158 ngx_http_log_commands, /* module directives */ |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
159 NGX_HTTP_MODULE, /* module type */ |
541 | 160 NULL, /* init master */ |
573 | 161 NULL, /* init module */ |
541 | 162 NULL, /* init process */ |
163 NULL, /* init thread */ | |
164 NULL, /* exit thread */ | |
165 NULL, /* exit process */ | |
166 NULL, /* exit master */ | |
167 NGX_MODULE_V1_PADDING | |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
168 }; |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
169 |
26
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
170 |
573 | 171 static ngx_str_t http_access_log = ngx_string(NGX_HTTP_LOG_PATH); |
172 | |
173 | |
174 static ngx_str_t ngx_http_combined_fmt = | |
581 | 175 ngx_string("$remote_addr - $remote_user [$time_local] " |
577 | 176 "\"$request\" $status $body_bytes_sent " |
573 | 177 "\"$http_referer\" \"$http_user_agent\""); |
119
cd54bcbaf3b5
nginx-0.0.1-2003-07-21-01:15:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
116
diff
changeset
|
178 |
26
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
179 |
573 | 180 static ngx_http_log_var_t ngx_http_log_vars[] = { |
181 { ngx_string("connection"), NGX_ATOMIC_T_LEN, ngx_http_log_connection }, | |
182 { ngx_string("pipe"), 1, ngx_http_log_pipe }, | |
581 | 183 { ngx_string("time_local"), sizeof("28/Sep/1970:12:00:00 +0600") - 1, |
573 | 184 ngx_http_log_time }, |
185 { ngx_string("msec"), NGX_TIME_T_LEN + 4, ngx_http_log_msec }, | |
186 { ngx_string("request_time"), NGX_TIME_T_LEN, ngx_http_log_request_time }, | |
187 { ngx_string("status"), 3, ngx_http_log_status }, | |
188 { ngx_string("bytes_sent"), NGX_OFF_T_LEN, ngx_http_log_bytes_sent }, | |
577 | 189 { ngx_string("body_bytes_sent"), NGX_OFF_T_LEN, |
190 ngx_http_log_body_bytes_sent }, | |
573 | 191 { ngx_string("apache_bytes_sent"), NGX_OFF_T_LEN, |
577 | 192 ngx_http_log_body_bytes_sent }, |
573 | 193 { ngx_string("request_length"), NGX_SIZE_T_LEN, |
194 ngx_http_log_request_length }, | |
195 | |
196 { ngx_null_string, 0, NULL } | |
197 }; | |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
198 |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
199 |
573 | 200 ngx_http_log_op_name_t ngx_http_log_fmt_ops[] = { |
479 | 201 { ngx_string("addr"), INET_ADDRSTRLEN - 1, NULL, NULL, ngx_http_log_addr }, |
493 | 202 { ngx_string("conn"), NGX_ATOMIC_T_LEN, NULL, NULL, |
203 ngx_http_log_connection }, | |
479 | 204 { ngx_string("pipe"), 1, NULL, NULL, ngx_http_log_pipe }, |
489 | 205 { ngx_string("time"), sizeof("28/Sep/1970:12:00:00 +0600") - 1, |
479 | 206 NULL, NULL, ngx_http_log_time }, |
207 { ngx_string("msec"), NGX_TIME_T_LEN + 4, NULL, NULL, ngx_http_log_msec }, | |
497 | 208 { ngx_string("request_time"), NGX_TIME_T_LEN, NULL, NULL, |
209 ngx_http_log_request_time }, | |
479 | 210 { ngx_string("status"), 3, NULL, NULL, ngx_http_log_status }, |
573 | 211 { ngx_string("length"), NGX_OFF_T_LEN, |
212 NULL, NULL, ngx_http_log_bytes_sent }, | |
479 | 213 { ngx_string("apache_length"), NGX_OFF_T_LEN, |
577 | 214 NULL, NULL, ngx_http_log_body_bytes_sent }, |
477 | 215 { ngx_string("request_length"), NGX_SIZE_T_LEN, |
493 | 216 NULL, NULL, ngx_http_log_request_length }, |
479 | 217 |
218 { ngx_string("request"), 0, NULL, | |
493 | 219 ngx_http_log_request_getlen, |
220 ngx_http_log_request }, | |
479 | 221 |
501 | 222 { ngx_string("i"), 0, ngx_http_log_header_in_compile, NULL, |
479 | 223 ngx_http_log_header_in }, |
501 | 224 { ngx_string("o"), 0, ngx_http_log_header_out_compile, NULL, |
479 | 225 ngx_http_log_header_out }, |
501 | 226 { ngx_string("v"), 0, ngx_http_log_variable_compile, NULL, |
227 ngx_http_log_variable }, | |
479 | 228 |
229 { ngx_null_string, 0, NULL, NULL, NULL } | |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
230 }; |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
231 |
26
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
232 |
497 | 233 ngx_int_t |
234 ngx_http_log_handler(ngx_http_request_t *r) | |
26
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
235 { |
290
87e73f067470
nginx-0.0.2-2004-03-16-10:10:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
282
diff
changeset
|
236 ngx_uint_t i, l; |
87e73f067470
nginx-0.0.2-2004-03-16-10:10:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
282
diff
changeset
|
237 u_char *line, *p; |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
238 size_t len; |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
239 ngx_http_log_t *log; |
571 | 240 ngx_open_file_t *file; |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
241 ngx_http_log_op_t *op; |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
242 ngx_http_log_loc_conf_t *lcf; |
26
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
243 |
210
00cafae0bdf1
nginx-0.0.1-2003-12-14-23:10:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
208
diff
changeset
|
244 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
00cafae0bdf1
nginx-0.0.1-2003-12-14-23:10:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
208
diff
changeset
|
245 "http log handler"); |
28
a117a7fdf042
nginx-0.0.1-2002-12-16-00:08:04 import
Igor Sysoev <igor@sysoev.ru>
parents:
26
diff
changeset
|
246 |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
247 lcf = ngx_http_get_module_loc_conf(r, ngx_http_log_module); |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
248 |
427
0d08eabe5c7b
nginx-0.0.10-2004-09-15-20:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
249 if (lcf->off) { |
0d08eabe5c7b
nginx-0.0.10-2004-09-15-20:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
250 return NGX_OK; |
0d08eabe5c7b
nginx-0.0.10-2004-09-15-20:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
251 } |
0d08eabe5c7b
nginx-0.0.10-2004-09-15-20:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
252 |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
253 log = lcf->logs->elts; |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
254 for (l = 0; l < lcf->logs->nelts; l++) { |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
255 |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
256 len = 0; |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
257 op = log[l].ops->elts; |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
258 for (i = 0; i < log[l].ops->nelts; i++) { |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
259 if (op[i].len == 0) { |
479 | 260 len += op[i].getlen(r, op[i].data); |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
261 |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
262 } else { |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
263 len += op[i].len; |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
264 } |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
265 } |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
266 |
571 | 267 len += NGX_LINEFEED_SIZE; |
268 | |
269 file = log[l].file; | |
270 | |
271 if (file->buffer) { | |
272 | |
273 if (len > (size_t) (file->last - file->pos)) { | |
274 | |
275 ngx_write_fd(file->fd, file->buffer, file->pos - file->buffer); | |
276 | |
277 file->pos = file->buffer; | |
278 } | |
279 | |
280 if (len <= (size_t) (file->last - file->pos)) { | |
281 | |
282 p = file->pos; | |
283 | |
284 for (i = 0; i < log[l].ops->nelts; i++) { | |
285 p = op[i].run(r, p, &op[i]); | |
286 } | |
287 | |
288 ngx_linefeed(p); | |
289 | |
290 file->pos = p; | |
291 | |
292 continue; | |
293 } | |
294 } | |
26
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
295 |
501 | 296 line = ngx_palloc(r->pool, len); |
297 if (line == NULL) { | |
473 | 298 return NGX_ERROR; |
299 } | |
300 | |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
301 p = line; |
26
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
302 |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
303 for (i = 0; i < log[l].ops->nelts; i++) { |
479 | 304 p = op[i].run(r, p, &op[i]); |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
305 } |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
306 |
571 | 307 ngx_linefeed(p); |
308 | |
309 ngx_write_fd(file->fd, line, p - line); | |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
310 } |
26
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
311 |
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
312 return NGX_OK; |
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
313 } |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
314 |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
315 |
497 | 316 static u_char * |
317 ngx_http_log_copy_short(ngx_http_request_t *r, u_char *buf, | |
318 ngx_http_log_op_t *op) | |
479 | 319 { |
320 size_t len; | |
321 uintptr_t data; | |
322 | |
323 len = op->len; | |
324 data = op->data; | |
325 | |
326 while (len--) { | |
327 *buf++ = (u_char) (data & 0xff); | |
328 data >>= 8; | |
329 } | |
330 | |
331 return buf; | |
332 } | |
333 | |
334 | |
497 | 335 static u_char * |
336 ngx_http_log_copy_long(ngx_http_request_t *r, u_char *buf, | |
337 ngx_http_log_op_t *op) | |
479 | 338 { |
339 return ngx_cpymem(buf, (u_char *) op->data, op->len); | |
340 } | |
341 | |
342 | |
497 | 343 static u_char * |
344 ngx_http_log_addr(ngx_http_request_t *r, u_char *buf, ngx_http_log_op_t *op) | |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
345 { |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
346 return ngx_cpymem(buf, r->connection->addr_text.data, |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
347 r->connection->addr_text.len); |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
348 } |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
349 |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
350 |
497 | 351 static u_char * |
352 ngx_http_log_connection(ngx_http_request_t *r, u_char *buf, | |
353 ngx_http_log_op_t *op) | |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
354 { |
455 | 355 return ngx_sprintf(buf, "%ui", r->connection->number); |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
356 } |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
357 |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
358 |
497 | 359 static u_char * |
360 ngx_http_log_pipe(ngx_http_request_t *r, u_char *buf, ngx_http_log_op_t *op) | |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
361 { |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
362 if (r->pipeline) { |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
363 *buf = 'p'; |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
364 } else { |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
365 *buf = '.'; |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
366 } |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
367 |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
368 return buf + 1; |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
369 } |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
370 |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
371 |
497 | 372 static u_char * |
373 ngx_http_log_time(ngx_http_request_t *r, u_char *buf, ngx_http_log_op_t *op) | |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
374 { |
178
a8ff48d26cca
nginx-0.0.1-2003-11-11-00:09:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
177
diff
changeset
|
375 return ngx_cpymem(buf, ngx_cached_http_log_time.data, |
a8ff48d26cca
nginx-0.0.1-2003-11-11-00:09:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
177
diff
changeset
|
376 ngx_cached_http_log_time.len); |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
377 } |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
378 |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
379 |
497 | 380 static u_char * |
381 ngx_http_log_msec(ngx_http_request_t *r, u_char *buf, ngx_http_log_op_t *op) | |
409
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
393
diff
changeset
|
382 { |
563 | 383 ngx_time_t *tp; |
409
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
393
diff
changeset
|
384 |
563 | 385 tp = ngx_timeofday(); |
409
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
393
diff
changeset
|
386 |
563 | 387 return ngx_sprintf(buf, "%T.%03M", tp->sec, tp->msec); |
409
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
393
diff
changeset
|
388 } |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
393
diff
changeset
|
389 |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
393
diff
changeset
|
390 |
497 | 391 static u_char * |
392 ngx_http_log_request_time(ngx_http_request_t *r, u_char *buf, | |
393 ngx_http_log_op_t *op) | |
394 { | |
395 time_t elapsed; | |
396 | |
397 elapsed = ngx_time() - r->start_time; | |
398 | |
399 return ngx_sprintf(buf, "%T", elapsed); | |
400 } | |
401 | |
402 | |
403 static size_t | |
404 ngx_http_log_request_getlen(ngx_http_request_t *r, uintptr_t data) | |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
405 { |
479 | 406 return r->request_line.len; |
407 } | |
408 | |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
409 |
497 | 410 static u_char * |
411 ngx_http_log_request(ngx_http_request_t *r, u_char *buf, ngx_http_log_op_t *op) | |
479 | 412 { |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
413 return ngx_cpymem(buf, r->request_line.data, r->request_line.len); |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
414 } |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
415 |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
416 |
497 | 417 static u_char * |
418 ngx_http_log_status(ngx_http_request_t *r, u_char *buf, ngx_http_log_op_t *op) | |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
419 { |
455 | 420 return ngx_sprintf(buf, "%ui", |
421 r->err_status ? r->err_status : r->headers_out.status); | |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
422 } |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
423 |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
424 |
497 | 425 static u_char * |
573 | 426 ngx_http_log_bytes_sent(ngx_http_request_t *r, u_char *buf, |
427 ngx_http_log_op_t *op) | |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
428 { |
455 | 429 return ngx_sprintf(buf, "%O", r->connection->sent); |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
430 } |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
431 |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
432 |
497 | 433 static u_char * |
577 | 434 ngx_http_log_body_bytes_sent(ngx_http_request_t *r, u_char *buf, |
497 | 435 ngx_http_log_op_t *op) |
210
00cafae0bdf1
nginx-0.0.1-2003-12-14-23:10:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
208
diff
changeset
|
436 { |
497 | 437 off_t length; |
438 | |
439 length = r->connection->sent - r->header_size; | |
440 | |
441 if (length > 0) { | |
442 return ngx_sprintf(buf, "%O", length); | |
443 } | |
444 | |
445 *buf = '0'; | |
446 | |
447 return buf + 1; | |
210
00cafae0bdf1
nginx-0.0.1-2003-12-14-23:10:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
208
diff
changeset
|
448 } |
00cafae0bdf1
nginx-0.0.1-2003-12-14-23:10:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
208
diff
changeset
|
449 |
00cafae0bdf1
nginx-0.0.1-2003-12-14-23:10:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
208
diff
changeset
|
450 |
497 | 451 static u_char * |
452 ngx_http_log_request_length(ngx_http_request_t *r, u_char *buf, | |
453 ngx_http_log_op_t *op) | |
475 | 454 { |
477 | 455 return ngx_sprintf(buf, "%z", r->request_length); |
475 | 456 } |
457 | |
458 | |
497 | 459 static ngx_int_t |
501 | 460 ngx_http_log_header_in_compile(ngx_conf_t *cf, ngx_http_log_op_t *op, |
461 ngx_str_t *value) | |
479 | 462 { |
463 ngx_uint_t i; | |
464 | |
465 op->len = 0; | |
466 | |
467 for (i = 0; ngx_http_headers_in[i].name.len != 0; i++) { | |
468 | |
469 if (ngx_http_headers_in[i].name.len != value->len) { | |
470 continue; | |
471 } | |
472 | |
509 | 473 /* STUB: "Cookie" speacial handling */ |
474 if (ngx_http_headers_in[i].offset == 0) { | |
475 continue; | |
476 } | |
477 | |
479 | 478 if (ngx_strncasecmp(ngx_http_headers_in[i].name.data, value->data, |
501 | 479 value->len) == 0) |
479 | 480 { |
481 op->getlen = ngx_http_log_header_in_getlen; | |
482 op->run = ngx_http_log_header_in; | |
483 op->data = ngx_http_headers_in[i].offset; | |
484 | |
485 return NGX_OK; | |
486 } | |
487 } | |
488 | |
489 op->getlen = ngx_http_log_unknown_header_in_getlen; | |
490 op->run = ngx_http_log_unknown_header_in; | |
491 op->data = (uintptr_t) value; | |
492 | |
493 return NGX_OK; | |
494 } | |
495 | |
496 | |
497 | 497 static size_t |
498 ngx_http_log_header_in_getlen(ngx_http_request_t *r, uintptr_t data) | |
479 | 499 { |
500 ngx_table_elt_t *h; | |
501 | |
502 h = *(ngx_table_elt_t **) ((char *) &r->headers_in + data); | |
503 | |
504 if (h) { | |
505 return h->value.len; | |
506 } | |
507 | |
508 return 1; | |
509 } | |
510 | |
511 | |
497 | 512 static u_char * |
513 ngx_http_log_header_in(ngx_http_request_t *r, u_char *buf, | |
514 ngx_http_log_op_t *op) | |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
515 { |
479 | 516 ngx_table_elt_t *h; |
517 | |
518 h = *(ngx_table_elt_t **) ((char *) &r->headers_in + op->data); | |
519 | |
520 if (h) { | |
521 return ngx_cpymem(buf, h->value.data, h->value.len); | |
522 } | |
523 | |
524 *buf = '-'; | |
525 | |
526 return buf + 1; | |
527 } | |
528 | |
529 | |
497 | 530 static size_t |
531 ngx_http_log_unknown_header_in_getlen(ngx_http_request_t *r, uintptr_t data) | |
479 | 532 { |
533 ngx_table_elt_t *h; | |
534 | |
535 h = ngx_http_log_unknown_header(&r->headers_in.headers, (ngx_str_t *) data); | |
536 | |
537 if (h) { | |
538 return h->value.len; | |
539 } | |
540 | |
541 return 1; | |
542 } | |
543 | |
544 | |
497 | 545 static u_char * |
546 ngx_http_log_unknown_header_in(ngx_http_request_t *r, u_char *buf, | |
547 ngx_http_log_op_t *op) | |
479 | 548 { |
549 ngx_table_elt_t *h; | |
550 | |
551 h = ngx_http_log_unknown_header(&r->headers_in.headers, | |
552 (ngx_str_t *) op->data); | |
553 | |
554 if (h) { | |
555 return ngx_cpymem(buf, h->value.data, h->value.len); | |
556 } | |
557 | |
558 *buf = '-'; | |
559 | |
560 return buf + 1; | |
561 } | |
562 | |
563 | |
497 | 564 static ngx_int_t |
501 | 565 ngx_http_log_header_out_compile(ngx_conf_t *cf, ngx_http_log_op_t *op, |
566 ngx_str_t *value) | |
479 | 567 { |
568 ngx_uint_t i; | |
569 | |
570 op->len = 0; | |
571 | |
572 for (i = 0; ngx_http_headers_out[i].name.len != 0; i++) { | |
573 | |
574 if (ngx_http_headers_out[i].name.len != value->len) { | |
575 continue; | |
576 } | |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
577 |
479 | 578 if (ngx_strncasecmp(ngx_http_headers_out[i].name.data, value->data, |
497 | 579 value->len) == 0) |
479 | 580 { |
581 op->getlen = ngx_http_log_header_out_getlen; | |
582 op->run = ngx_http_log_header_out; | |
583 op->data = ngx_http_headers_out[i].offset; | |
584 | |
585 return NGX_OK; | |
586 } | |
587 } | |
588 | |
589 if (value->len == sizeof("Connection") - 1 | |
590 && ngx_strncasecmp(value->data, "Connection", value->len) == 0) | |
591 { | |
592 op->len = sizeof("keep-alive") - 1; | |
593 op->getlen = NULL; | |
594 op->run = ngx_http_log_connection_header_out; | |
595 op->data = 0; | |
596 return NGX_OK; | |
597 } | |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
598 |
479 | 599 if (value->len == sizeof("Transfer-Encoding") - 1 |
600 && ngx_strncasecmp(value->data, "Transfer-Encoding", value->len) == 0) | |
601 { | |
602 op->len = sizeof("chunked") - 1; | |
603 op->getlen = NULL; | |
604 op->run = ngx_http_log_transfer_encoding_header_out; | |
605 op->data = 0; | |
606 return NGX_OK; | |
607 } | |
608 | |
609 op->getlen = ngx_http_log_unknown_header_out_getlen; | |
610 op->run = ngx_http_log_unknown_header_out; | |
611 op->data = (uintptr_t) value; | |
612 | |
613 return NGX_OK; | |
614 } | |
615 | |
616 | |
497 | 617 static size_t |
618 ngx_http_log_header_out_getlen(ngx_http_request_t *r, uintptr_t data) | |
479 | 619 { |
620 ngx_table_elt_t *h; | |
621 | |
622 h = *(ngx_table_elt_t **) ((char *) &r->headers_out + data); | |
623 | |
624 if (h) { | |
625 return h->value.len; | |
626 } | |
627 | |
628 /* | |
629 * No header pointer was found. | |
630 * However, some headers: "Date", "Server", "Content-Length", | |
505 | 631 * and "Last-Modified" have a special handling in the header filter, |
632 * but we do not set up their pointers in the filter, | |
633 * because they are too seldom needed to be logged. | |
479 | 634 */ |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
635 |
479 | 636 if (data == offsetof(ngx_http_headers_out_t, date)) { |
637 return ngx_cached_http_time.len; | |
638 } | |
639 | |
640 if (data == offsetof(ngx_http_headers_out_t, server)) { | |
641 return (sizeof(NGINX_VER) - 1); | |
642 } | |
643 | |
644 if (data == offsetof(ngx_http_headers_out_t, content_length)) { | |
645 if (r->headers_out.content_length_n == -1) { | |
646 return 1; | |
647 } | |
648 | |
649 return NGX_OFF_T_LEN; | |
650 } | |
651 | |
652 if (data == offsetof(ngx_http_headers_out_t, last_modified)) { | |
653 if (r->headers_out.last_modified_time == -1) { | |
654 return 1; | |
655 } | |
656 | |
657 return sizeof("Mon, 28 Sep 1970 06:00:00 GMT") - 1; | |
658 } | |
659 | |
660 return 1; | |
661 } | |
662 | |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
663 |
497 | 664 static u_char * |
665 ngx_http_log_header_out(ngx_http_request_t *r, u_char *buf, | |
666 ngx_http_log_op_t *op) | |
479 | 667 { |
668 ngx_table_elt_t *h; | |
669 | |
670 h = *(ngx_table_elt_t **) ((char *) &r->headers_out + op->data); | |
671 | |
672 if (h) { | |
673 return ngx_cpymem(buf, h->value.data, h->value.len); | |
674 } | |
675 | |
676 /* | |
677 * No header pointer was found. | |
678 * However, some headers: "Date", "Server", "Content-Length", | |
505 | 679 * and "Last-Modified" have a special handling in the header filter, |
680 * but we do not set up their pointers in the filter, | |
681 * because they are too seldom needed to be logged. | |
479 | 682 */ |
683 | |
684 if (op->data == offsetof(ngx_http_headers_out_t, date)) { | |
685 return ngx_cpymem(buf, ngx_cached_http_time.data, | |
686 ngx_cached_http_time.len); | |
687 } | |
688 | |
689 if (op->data == offsetof(ngx_http_headers_out_t, server)) { | |
690 return ngx_cpymem(buf, NGINX_VER, sizeof(NGINX_VER) - 1); | |
691 } | |
692 | |
693 if (op->data == offsetof(ngx_http_headers_out_t, content_length)) { | |
694 if (r->headers_out.content_length_n == -1) { | |
695 *buf = '-'; | |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
696 |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
697 return buf + 1; |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
698 } |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
699 |
479 | 700 return ngx_sprintf(buf, "%O", r->headers_out.content_length_n); |
701 } | |
702 | |
703 if (op->data == offsetof(ngx_http_headers_out_t, last_modified)) { | |
704 if (r->headers_out.last_modified_time == -1) { | |
705 *buf = '-'; | |
706 | |
707 return buf + 1; | |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
708 } |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
709 |
479 | 710 return ngx_http_time(buf, r->headers_out.last_modified_time); |
711 } | |
712 | |
713 *buf = '-'; | |
714 | |
715 return buf + 1; | |
716 } | |
717 | |
718 | |
497 | 719 static size_t |
720 ngx_http_log_unknown_header_out_getlen(ngx_http_request_t *r, uintptr_t data) | |
479 | 721 { |
722 ngx_table_elt_t *h; | |
723 | |
724 h = ngx_http_log_unknown_header(&r->headers_out.headers, | |
725 (ngx_str_t *) data); | |
726 | |
727 if (h) { | |
728 return h->value.len; | |
729 } | |
730 | |
731 return 1; | |
732 } | |
733 | |
734 | |
497 | 735 static u_char * |
736 ngx_http_log_unknown_header_out(ngx_http_request_t *r, u_char *buf, | |
737 ngx_http_log_op_t *op) | |
479 | 738 { |
739 ngx_table_elt_t *h; | |
740 | |
741 h = ngx_http_log_unknown_header(&r->headers_out.headers, | |
742 (ngx_str_t *) op->data); | |
743 | |
744 if (h) { | |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
745 return ngx_cpymem(buf, h->value.data, h->value.len); |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
746 } |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
747 |
479 | 748 *buf = '-'; |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
749 |
479 | 750 return buf + 1; |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
751 } |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
752 |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
753 |
497 | 754 static ngx_table_elt_t * |
755 ngx_http_log_unknown_header(ngx_list_t *headers, ngx_str_t *value) | |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
756 { |
290
87e73f067470
nginx-0.0.2-2004-03-16-10:10:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
282
diff
changeset
|
757 ngx_uint_t i; |
415
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
758 ngx_list_part_t *part; |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
759 ngx_table_elt_t *h; |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
760 |
479 | 761 part = &headers->part; |
415
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
762 h = part->elts; |
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
763 |
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
764 for (i = 0; /* void */; i++) { |
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
765 |
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
766 if (i >= part->nelts) { |
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
767 if (part->next == NULL) { |
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
768 break; |
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
769 } |
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
770 |
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
771 part = part->next; |
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
772 h = part->elts; |
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
773 i = 0; |
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
774 } |
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
775 |
479 | 776 if (h[i].key.len != value->len) { |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
777 continue; |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
778 } |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
779 |
479 | 780 if (ngx_strncasecmp(h[i].key.data, value->data, value->len) == 0) { |
781 return &h[i]; | |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
782 } |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
783 } |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
784 |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
785 return NULL; |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
786 } |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
787 |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
788 |
497 | 789 static u_char * |
790 ngx_http_log_connection_header_out(ngx_http_request_t *r, u_char *buf, | |
791 ngx_http_log_op_t *op) | |
208
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
792 { |
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
793 if (r->keepalive) { |
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
794 return ngx_cpymem(buf, "keep-alive", sizeof("keep-alive") - 1); |
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
795 |
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
796 } else { |
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
797 return ngx_cpymem(buf, "close", sizeof("close") - 1); |
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
798 } |
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
799 } |
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
800 |
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
801 |
497 | 802 static u_char * |
803 ngx_http_log_transfer_encoding_header_out(ngx_http_request_t *r, u_char *buf, | |
804 ngx_http_log_op_t *op) | |
208
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
805 { |
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
806 if (r->chunked) { |
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
807 return ngx_cpymem(buf, "chunked", sizeof("chunked") - 1); |
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
808 } |
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
809 |
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
810 *buf = '-'; |
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
811 |
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
812 return buf + 1; |
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
813 } |
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
814 |
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
815 |
577 | 816 static ngx_int_t |
501 | 817 ngx_http_log_variable_compile(ngx_conf_t *cf, ngx_http_log_op_t *op, |
818 ngx_str_t *value) | |
819 { | |
509 | 820 ngx_int_t index; |
501 | 821 |
509 | 822 index = ngx_http_get_variable_index(cf, value); |
823 if (index == NGX_ERROR) { | |
501 | 824 return NGX_ERROR; |
825 } | |
826 | |
827 op->len = 0; | |
828 op->getlen = ngx_http_log_variable_getlen; | |
829 op->run = ngx_http_log_variable; | |
509 | 830 op->data = index; |
501 | 831 |
832 return NGX_OK; | |
833 } | |
834 | |
835 | |
836 static size_t | |
837 ngx_http_log_variable_getlen(ngx_http_request_t *r, uintptr_t data) | |
838 { | |
839 ngx_http_variable_value_t *value; | |
840 | |
841 value = ngx_http_get_indexed_variable(r, data); | |
842 | |
573 | 843 if (value == NULL || value->not_found) { |
501 | 844 return 1; |
845 } | |
846 | |
573 | 847 return value->len; |
501 | 848 } |
849 | |
850 | |
851 static u_char * | |
852 ngx_http_log_variable(ngx_http_request_t *r, u_char *buf, ngx_http_log_op_t *op) | |
853 { | |
854 ngx_http_variable_value_t *value; | |
855 | |
856 value = ngx_http_get_indexed_variable(r, op->data); | |
857 | |
573 | 858 if (value == NULL || value->not_found) { |
501 | 859 *buf = '-'; |
860 return buf + 1; | |
861 } | |
862 | |
573 | 863 return ngx_cpymem(buf, value->data, value->len); |
501 | 864 } |
865 | |
866 | |
497 | 867 static ngx_int_t |
868 ngx_http_log_set_formats(ngx_conf_t *cf) | |
177
4db54fdbcbe7
nginx-0.0.1-2003-11-10-20:17:31 import
Igor Sysoev <igor@sysoev.ru>
parents:
176
diff
changeset
|
869 { |
4db54fdbcbe7
nginx-0.0.1-2003-11-10-20:17:31 import
Igor Sysoev <igor@sysoev.ru>
parents:
176
diff
changeset
|
870 ngx_http_log_op_name_t *op; |
4db54fdbcbe7
nginx-0.0.1-2003-11-10-20:17:31 import
Igor Sysoev <igor@sysoev.ru>
parents:
176
diff
changeset
|
871 |
4db54fdbcbe7
nginx-0.0.1-2003-11-10-20:17:31 import
Igor Sysoev <igor@sysoev.ru>
parents:
176
diff
changeset
|
872 for (op = ngx_http_log_fmt_ops; op->name.len; op++) { /* void */ } |
479 | 873 op->run = NULL; |
177
4db54fdbcbe7
nginx-0.0.1-2003-11-10-20:17:31 import
Igor Sysoev <igor@sysoev.ru>
parents:
176
diff
changeset
|
874 |
4db54fdbcbe7
nginx-0.0.1-2003-11-10-20:17:31 import
Igor Sysoev <igor@sysoev.ru>
parents:
176
diff
changeset
|
875 return NGX_OK; |
4db54fdbcbe7
nginx-0.0.1-2003-11-10-20:17:31 import
Igor Sysoev <igor@sysoev.ru>
parents:
176
diff
changeset
|
876 } |
4db54fdbcbe7
nginx-0.0.1-2003-11-10-20:17:31 import
Igor Sysoev <igor@sysoev.ru>
parents:
176
diff
changeset
|
877 |
4db54fdbcbe7
nginx-0.0.1-2003-11-10-20:17:31 import
Igor Sysoev <igor@sysoev.ru>
parents:
176
diff
changeset
|
878 |
497 | 879 static void * |
880 ngx_http_log_create_main_conf(ngx_conf_t *cf) | |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
881 { |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
882 ngx_http_log_main_conf_t *conf; |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
883 |
573 | 884 ngx_http_log_fmt_t *fmt; |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
885 |
501 | 886 conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_log_main_conf_t)); |
887 if (conf == NULL) { | |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
888 return NGX_CONF_ERROR; |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
889 } |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
890 |
497 | 891 if (ngx_array_init(&conf->formats, cf->pool, 4, sizeof(ngx_http_log_fmt_t)) |
573 | 892 != NGX_OK) |
497 | 893 { |
894 return NGX_CONF_ERROR; | |
895 } | |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
896 |
573 | 897 fmt = ngx_array_push(&conf->formats); |
898 if (fmt == NULL) { | |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
899 return NGX_CONF_ERROR; |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
900 } |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
901 |
573 | 902 fmt->name.len = sizeof("combined") - 1; |
903 fmt->name.data = (u_char *) "combined"; | |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
904 |
573 | 905 fmt->ops = ngx_array_create(cf->pool, 16, sizeof(ngx_http_log_op_t)); |
906 if (fmt->ops == NULL) { | |
569 | 907 return NGX_CONF_ERROR; |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
908 } |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
909 |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
910 return conf; |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
911 } |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
912 |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
913 |
497 | 914 static void * |
915 ngx_http_log_create_loc_conf(ngx_conf_t *cf) | |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
916 { |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
917 ngx_http_log_loc_conf_t *conf; |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
918 |
501 | 919 conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_log_loc_conf_t)); |
920 if (conf == NULL) { | |
427
0d08eabe5c7b
nginx-0.0.10-2004-09-15-20:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
921 return NGX_CONF_ERROR; |
0d08eabe5c7b
nginx-0.0.10-2004-09-15-20:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
922 } |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
923 |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
924 return conf; |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
925 } |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
926 |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
927 |
497 | 928 static char * |
929 ngx_http_log_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child) | |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
930 { |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
931 ngx_http_log_loc_conf_t *prev = parent; |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
932 ngx_http_log_loc_conf_t *conf = child; |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
933 |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
934 ngx_http_log_t *log; |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
935 ngx_http_log_fmt_t *fmt; |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
936 ngx_http_log_main_conf_t *lmcf; |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
937 |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
938 if (conf->logs == NULL) { |
427
0d08eabe5c7b
nginx-0.0.10-2004-09-15-20:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
939 |
0d08eabe5c7b
nginx-0.0.10-2004-09-15-20:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
940 if (conf->off) { |
0d08eabe5c7b
nginx-0.0.10-2004-09-15-20:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
941 return NGX_CONF_OK; |
0d08eabe5c7b
nginx-0.0.10-2004-09-15-20:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
942 } |
0d08eabe5c7b
nginx-0.0.10-2004-09-15-20:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
943 |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
944 if (prev->logs) { |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
945 conf->logs = prev->logs; |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
946 |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
947 } else { |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
948 |
427
0d08eabe5c7b
nginx-0.0.10-2004-09-15-20:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
949 if (prev->off) { |
0d08eabe5c7b
nginx-0.0.10-2004-09-15-20:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
950 conf->off = prev->off; |
0d08eabe5c7b
nginx-0.0.10-2004-09-15-20:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
951 return NGX_CONF_OK; |
0d08eabe5c7b
nginx-0.0.10-2004-09-15-20:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
952 } |
0d08eabe5c7b
nginx-0.0.10-2004-09-15-20:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
953 |
0d08eabe5c7b
nginx-0.0.10-2004-09-15-20:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
954 conf->logs = ngx_array_create(cf->pool, 2, sizeof(ngx_http_log_t)); |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
955 if (conf->logs == NULL) { |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
956 return NGX_CONF_ERROR; |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
957 } |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
958 |
501 | 959 log = ngx_array_push(conf->logs); |
960 if (log == NULL) { | |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
961 return NGX_CONF_ERROR; |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
962 } |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
963 |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
964 log->file = ngx_conf_open_file(cf->cycle, &http_access_log); |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
965 if (log->file == NULL) { |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
966 return NGX_CONF_ERROR; |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
967 } |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
968 |
393
5659d773cfa8
nginx-0.0.7-2004-07-15-20:35:51 import
Igor Sysoev <igor@sysoev.ru>
parents:
356
diff
changeset
|
969 lmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_log_module); |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
970 fmt = lmcf->formats.elts; |
427
0d08eabe5c7b
nginx-0.0.10-2004-09-15-20:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
971 |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
972 /* the default "combined" format */ |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
973 log->ops = fmt[0].ops; |
573 | 974 lmcf->combined_used = 1; |
119
cd54bcbaf3b5
nginx-0.0.1-2003-07-21-01:15:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
116
diff
changeset
|
975 } |
cd54bcbaf3b5
nginx-0.0.1-2003-07-21-01:15:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
116
diff
changeset
|
976 } |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
977 |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
978 return NGX_CONF_OK; |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
979 } |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
980 |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
981 |
497 | 982 static char * |
983 ngx_http_log_set_log(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) | |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
984 { |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
985 ngx_http_log_loc_conf_t *llcf = conf; |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
986 |
571 | 987 ssize_t buf; |
290
87e73f067470
nginx-0.0.2-2004-03-16-10:10:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
282
diff
changeset
|
988 ngx_uint_t i; |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
989 ngx_str_t *value, name; |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
990 ngx_http_log_t *log; |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
991 ngx_http_log_fmt_t *fmt; |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
992 ngx_http_log_main_conf_t *lmcf; |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
993 |
427
0d08eabe5c7b
nginx-0.0.10-2004-09-15-20:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
994 value = cf->args->elts; |
0d08eabe5c7b
nginx-0.0.10-2004-09-15-20:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
995 |
0d08eabe5c7b
nginx-0.0.10-2004-09-15-20:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
996 if (ngx_strcmp(value[1].data, "off") == 0) { |
0d08eabe5c7b
nginx-0.0.10-2004-09-15-20:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
997 llcf->off = 1; |
0d08eabe5c7b
nginx-0.0.10-2004-09-15-20:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
998 return NGX_CONF_OK; |
0d08eabe5c7b
nginx-0.0.10-2004-09-15-20:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
999 } |
0d08eabe5c7b
nginx-0.0.10-2004-09-15-20:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
1000 |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1001 if (llcf->logs == NULL) { |
427
0d08eabe5c7b
nginx-0.0.10-2004-09-15-20:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
1002 llcf->logs = ngx_array_create(cf->pool, 2, sizeof(ngx_http_log_t)); |
0d08eabe5c7b
nginx-0.0.10-2004-09-15-20:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
1003 if (llcf->logs == NULL) { |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1004 return NGX_CONF_ERROR; |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1005 } |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1006 } |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
1007 |
393
5659d773cfa8
nginx-0.0.7-2004-07-15-20:35:51 import
Igor Sysoev <igor@sysoev.ru>
parents:
356
diff
changeset
|
1008 lmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_log_module); |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
1009 |
501 | 1010 log = ngx_array_push(llcf->logs); |
1011 if (log == NULL) { | |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1012 return NGX_CONF_ERROR; |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1013 } |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1014 |
501 | 1015 log->file = ngx_conf_open_file(cf->cycle, &value[1]); |
1016 if (log->file == NULL) { | |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1017 return NGX_CONF_ERROR; |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1018 } |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1019 |
571 | 1020 if (cf->args->nelts >= 3) { |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1021 name = value[2]; |
581 | 1022 |
1023 if (ngx_strcmp(name.data, "combined") == 0) { | |
1024 lmcf->combined_used = 1; | |
1025 } | |
1026 | |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1027 } else { |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1028 name.len = sizeof("combined") - 1; |
292
a472bfb778b3
nginx-0.0.3-2004-03-17-00:26:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
1029 name.data = (u_char *) "combined"; |
573 | 1030 lmcf->combined_used = 1; |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1031 } |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1032 |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1033 fmt = lmcf->formats.elts; |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1034 for (i = 0; i < lmcf->formats.nelts; i++) { |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1035 if (fmt[i].name.len == name.len |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1036 && ngx_strcasecmp(fmt[i].name.data, name.data) == 0) |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1037 { |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1038 log->ops = fmt[i].ops; |
571 | 1039 goto buffer; |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1040 } |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1041 } |
100
7ebc8b7fb816
nginx-0.0.1-2003-06-03-19:42:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
99
diff
changeset
|
1042 |
487 | 1043 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
1044 "unknown log format \"%V\"", &name); | |
571 | 1045 return NGX_CONF_ERROR; |
487 | 1046 |
571 | 1047 buffer: |
1048 | |
1049 if (cf->args->nelts == 4) { | |
1050 if (ngx_strncmp(value[3].data, "buffer=", 7) != 0) { | |
1051 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
1052 "invalid parameter \"%V\"", &value[3]); | |
1053 return NGX_CONF_ERROR; | |
1054 } | |
1055 | |
1056 name.len = value[3].len - 7; | |
1057 name.data = value[3].data + 7; | |
1058 | |
1059 buf = ngx_parse_size(&name); | |
1060 | |
1061 if (buf == NGX_ERROR) { | |
1062 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
1063 "invalid parameter \"%V\"", &value[3]); | |
1064 return NGX_CONF_ERROR; | |
1065 } | |
1066 | |
1067 if (log->file->buffer && log->file->last - log->file->pos != buf) { | |
1068 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
1069 "access_log \"%V\" already defined " | |
1070 "with different buffer size", &value[1]); | |
1071 return NGX_CONF_ERROR; | |
1072 } | |
1073 | |
1074 log->file->buffer = ngx_palloc(cf->pool, buf); | |
1075 if (log->file->buffer == NULL) { | |
1076 return NGX_CONF_ERROR; | |
1077 } | |
1078 | |
1079 log->file->pos = log->file->buffer; | |
1080 log->file->last = log->file->buffer + buf; | |
1081 } | |
1082 | |
1083 return NGX_CONF_OK; | |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
1084 } |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1085 |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1086 |
497 | 1087 static char * |
1088 ngx_http_log_set_format(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) | |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1089 { |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1090 ngx_http_log_main_conf_t *lmcf = conf; |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1091 |
573 | 1092 ngx_str_t *value; |
1093 ngx_uint_t i; | |
1094 ngx_http_log_fmt_t *fmt; | |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1095 |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1096 value = cf->args->elts; |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1097 |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1098 fmt = lmcf->formats.elts; |
573 | 1099 for (i = 0; i < lmcf->formats.nelts; i++) { |
1100 if (fmt[i].name.len == value[1].len | |
1101 && ngx_strcmp(fmt[i].name.data, value[1].data) == 0) | |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1102 { |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1103 return "duplicate \"log_format\" name"; |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1104 } |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1105 } |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1106 |
501 | 1107 fmt = ngx_array_push(&lmcf->formats); |
1108 if (fmt == NULL) { | |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1109 return NGX_CONF_ERROR; |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1110 } |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1111 |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1112 fmt->name = value[1]; |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1113 |
573 | 1114 fmt->ops = ngx_array_create(cf->pool, 16, sizeof(ngx_http_log_op_t)); |
501 | 1115 if (fmt->ops == NULL) { |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1116 return NGX_CONF_ERROR; |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1117 } |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1118 |
573 | 1119 return ngx_http_log_compile_format(cf, fmt->ops, cf->args, 2); |
1120 } | |
1121 | |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1122 |
573 | 1123 static char * |
1124 ngx_http_log_compile_format(ngx_conf_t *cf, ngx_array_t *ops, | |
1125 ngx_array_t *args, ngx_uint_t s) | |
1126 { | |
1127 u_char *data, *p, *fname, *arg_data, ch; | |
1128 size_t i, len, fname_len, arg_len; | |
1129 ngx_str_t *value, var, *a; | |
1130 ngx_uint_t bracket; | |
1131 ngx_http_log_op_t *op; | |
1132 ngx_http_log_var_t *v; | |
1133 ngx_http_log_op_name_t *name; | |
1134 static ngx_uint_t warn; | |
1135 | |
1136 value = args->elts; | |
1137 arg_data = NULL; | |
1138 | |
1139 for ( /* void */ ; s < args->nelts; s++) { | |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1140 |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1141 i = 0; |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1142 |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1143 while (i < value[s].len) { |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1144 |
573 | 1145 op = ngx_array_push(ops); |
501 | 1146 if (op == NULL) { |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1147 return NGX_CONF_ERROR; |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1148 } |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1149 |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1150 data = &value[s].data[i]; |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1151 |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1152 if (value[s].data[i] == '%') { |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1153 i++; |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1154 |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1155 if (i == value[s].len) { |
569 | 1156 goto invalid; |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1157 } |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1158 |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1159 if (value[s].data[i] == '{') { |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1160 i++; |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1161 |
573 | 1162 arg_data = &value[s].data[i]; |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1163 |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1164 while (i < value[s].len && value[s].data[i] != '}') { |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1165 i++; |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1166 } |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1167 |
573 | 1168 arg_len = &value[s].data[i] - arg_data; |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1169 |
573 | 1170 if (i == value[s].len || arg_len == 0) { |
569 | 1171 goto invalid; |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1172 } |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1173 |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1174 i++; |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1175 |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1176 } else { |
573 | 1177 arg_len = 0; |
1178 } | |
1179 | |
1180 if (warn == 0) { | |
1181 ngx_conf_log_error(NGX_LOG_WARN, cf, 0, | |
1182 "the parameters in the \"%%name\" form are deprecated, " | |
1183 "use the \"$variable\" instead"); | |
1184 warn = 1; | |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1185 } |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1186 |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1187 fname = &value[s].data[i]; |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1188 |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1189 while (i < value[s].len |
177
4db54fdbcbe7
nginx-0.0.1-2003-11-10-20:17:31 import
Igor Sysoev <igor@sysoev.ru>
parents:
176
diff
changeset
|
1190 && ((value[s].data[i] >= 'a' && value[s].data[i] <= 'z') |
4db54fdbcbe7
nginx-0.0.1-2003-11-10-20:17:31 import
Igor Sysoev <igor@sysoev.ru>
parents:
176
diff
changeset
|
1191 || value[s].data[i] == '_')) |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1192 { |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1193 i++; |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1194 } |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1195 |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1196 fname_len = &value[s].data[i] - fname; |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1197 |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1198 if (fname_len == 0) { |
569 | 1199 goto invalid; |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1200 } |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1201 |
479 | 1202 for (name = ngx_http_log_fmt_ops; name->run; name++) { |
177
4db54fdbcbe7
nginx-0.0.1-2003-11-10-20:17:31 import
Igor Sysoev <igor@sysoev.ru>
parents:
176
diff
changeset
|
1203 if (name->name.len == 0) { |
479 | 1204 name = (ngx_http_log_op_name_t *) name->run; |
177
4db54fdbcbe7
nginx-0.0.1-2003-11-10-20:17:31 import
Igor Sysoev <igor@sysoev.ru>
parents:
176
diff
changeset
|
1205 } |
4db54fdbcbe7
nginx-0.0.1-2003-11-10-20:17:31 import
Igor Sysoev <igor@sysoev.ru>
parents:
176
diff
changeset
|
1206 |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1207 if (name->name.len == fname_len |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1208 && ngx_strncmp(name->name.data, fname, fname_len) == 0) |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1209 { |
479 | 1210 if (name->compile == NULL) { |
573 | 1211 if (arg_len) { |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1212 fname[fname_len] = '\0'; |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1213 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1214 "\"%s\" must not have argument", |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1215 data); |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1216 return NGX_CONF_ERROR; |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1217 } |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1218 |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1219 op->len = name->len; |
479 | 1220 op->getlen = name->getlen; |
1221 op->run = name->run; | |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1222 op->data = 0; |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1223 |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1224 break; |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1225 } |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1226 |
573 | 1227 if (arg_len == 0) { |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1228 fname[fname_len] = '\0'; |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1229 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
577 | 1230 "\"%s\" requires argument", |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1231 data); |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1232 return NGX_CONF_ERROR; |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1233 } |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1234 |
501 | 1235 a = ngx_palloc(cf->pool, sizeof(ngx_str_t)); |
1236 if (a == NULL) { | |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1237 return NGX_CONF_ERROR; |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1238 } |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1239 |
573 | 1240 a->len = arg_len; |
1241 a->data = arg_data; | |
1242 | |
501 | 1243 if (name->compile(cf, op, a) == NGX_ERROR) { |
479 | 1244 return NGX_CONF_ERROR; |
1245 } | |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1246 |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1247 break; |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1248 } |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1249 } |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1250 |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1251 if (name->name.len == 0) { |
569 | 1252 goto invalid; |
1253 } | |
1254 | |
573 | 1255 continue; |
1256 | |
569 | 1257 } else if (value[s].data[i] == '$') { |
1258 | |
1259 if (++i == value[s].len) { | |
1260 goto invalid; | |
1261 } | |
1262 | |
1263 if (value[s].data[i] == '{') { | |
1264 bracket = 1; | |
1265 | |
1266 if (++i == value[s].len) { | |
1267 goto invalid; | |
1268 } | |
1269 | |
1270 var.data = &value[s].data[i]; | |
1271 | |
1272 } else { | |
1273 bracket = 0; | |
1274 var.data = &value[s].data[i]; | |
1275 } | |
1276 | |
1277 for (var.len = 0; i < value[s].len; i++, var.len++) { | |
1278 ch = value[s].data[i]; | |
1279 | |
1280 if (ch == '}' && bracket) { | |
1281 i++; | |
1282 bracket = 0; | |
1283 break; | |
1284 } | |
1285 | |
1286 if ((ch >= 'A' && ch <= 'Z') | |
1287 || (ch >= 'a' && ch <= 'z') | |
1288 || (ch >= '0' && ch <= '9') | |
1289 || ch == '_') | |
1290 { | |
1291 continue; | |
1292 } | |
1293 | |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1294 break; |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1295 } |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1296 |
569 | 1297 if (bracket) { |
1298 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
1299 "the closing bracket in \"%V\" " | |
1300 "variable is missing", &var); | |
1301 return NGX_CONF_ERROR; | |
1302 } | |
1303 | |
1304 if (var.len == 0) { | |
1305 goto invalid; | |
1306 } | |
1307 | |
577 | 1308 if (ngx_strncmp(var.data, "apache_bytes_sent", 17) == 0) { |
1309 ngx_conf_log_error(NGX_LOG_WARN, cf, 0, | |
1310 "use \"$body_bytes_sent\" instead of " | |
1311 "\"$apache_bytes_sent\""); | |
1312 } | |
1313 | |
573 | 1314 for (v = ngx_http_log_vars; v->name.len; v++) { |
1315 | |
1316 if (v->name.len == var.len | |
1317 && ngx_strncmp(v->name.data, var.data, var.len) == 0) | |
1318 { | |
1319 op->len = v->len; | |
1320 op->getlen = NULL; | |
1321 op->run = v->run; | |
1322 op->data = 0; | |
1323 | |
1324 goto found; | |
1325 } | |
1326 } | |
1327 | |
569 | 1328 if (ngx_http_log_variable_compile(cf, op, &var) != NGX_OK) { |
1329 return NGX_CONF_ERROR; | |
1330 } | |
1331 | |
573 | 1332 found: |
1333 | |
1334 continue; | |
1335 } | |
1336 | |
1337 i++; | |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1338 |
573 | 1339 while (i < value[s].len |
1340 && value[s].data[i] != '$' | |
1341 && value[s].data[i] != '%') | |
1342 { | |
1343 i++; | |
1344 } | |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1345 |
573 | 1346 len = &value[s].data[i] - data; |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1347 |
573 | 1348 if (len) { |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1349 |
573 | 1350 op->len = len; |
1351 op->getlen = NULL; | |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1352 |
573 | 1353 if (len <= sizeof(uintptr_t)) { |
1354 op->run = ngx_http_log_copy_short; | |
1355 op->data = 0; | |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1356 |
573 | 1357 while (len--) { |
1358 op->data <<= 8; | |
1359 op->data |= data[len]; | |
1360 } | |
1361 | |
1362 } else { | |
1363 op->run = ngx_http_log_copy_long; | |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1364 |
573 | 1365 p = ngx_palloc(cf->pool, len); |
1366 if (p == NULL) { | |
1367 return NGX_CONF_ERROR; | |
1368 } | |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1369 |
573 | 1370 ngx_memcpy(p, data, len); |
1371 op->data = (uintptr_t) p; | |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1372 } |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1373 } |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1374 } |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1375 } |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1376 |
569 | 1377 return NGX_CONF_OK; |
1378 | |
1379 invalid: | |
1380 | |
1381 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "invalid parameter \"%s\"", data); | |
1382 | |
1383 return NGX_CONF_ERROR; | |
1384 } | |
1385 | |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1386 |
569 | 1387 static ngx_int_t |
573 | 1388 ngx_http_log_init(ngx_conf_t *cf) |
569 | 1389 { |
573 | 1390 ngx_str_t *value; |
1391 ngx_array_t a; | |
581 | 1392 ngx_http_handler_pt *h; |
573 | 1393 ngx_http_log_fmt_t *fmt; |
1394 ngx_http_log_main_conf_t *lmcf; | |
569 | 1395 ngx_http_core_main_conf_t *cmcf; |
1396 | |
573 | 1397 lmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_log_module); |
1398 | |
1399 if (lmcf->combined_used) { | |
1400 if (ngx_array_init(&a, cf->pool, 1, sizeof(ngx_str_t)) != NGX_OK) { | |
1401 return NGX_ERROR; | |
1402 } | |
1403 | |
1404 value = ngx_array_push(&a); | |
1405 if (value == NULL) { | |
1406 return NGX_ERROR; | |
1407 } | |
1408 | |
1409 *value = ngx_http_combined_fmt; | |
1410 fmt = lmcf->formats.elts; | |
1411 | |
1412 if (ngx_http_log_compile_format(cf, fmt->ops, &a, 0) | |
1413 != NGX_CONF_OK) | |
1414 { | |
1415 return NGX_ERROR; | |
1416 } | |
1417 } | |
1418 | |
1419 cmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_core_module); | |
569 | 1420 |
581 | 1421 h = ngx_array_push(&cmcf->phases[NGX_HTTP_LOG_PHASE].handlers); |
1422 if (h == NULL) { | |
1423 return NGX_ERROR; | |
1424 } | |
1425 | |
1426 *h = ngx_http_log_handler; | |
569 | 1427 |
1428 return NGX_OK; | |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1429 } |