Mercurial > hg > nginx
annotate src/http/modules/ngx_http_log_module.c @ 3440:88741ec7731a stable-0.7
merge r3294, r3305:
Fix a bug introduced in r2032: After a child process has read a terminate
message from a channel, the process tries to read the channel again.
The kernel (at least FreeBSD) may preempt the process and sends a SIGIO
signal to a master process. The master process sends a new terminate message,
the kernel switches again to the the child process, and the child process
reads the messages instead of an EAGAIN error. And this may repeat over
and over. Being that the child process can not exit the cycle and test
the termination flag set by the message handler.
The fix disallow the master process to send a new terminate message on
SIGIO signal reception. It may send the message only on SIGALARM signal.
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Mon, 01 Feb 2010 15:49:36 +0000 |
parents | 3354dfba9da4 |
children |
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> |
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
10 |
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
11 |
880 | 12 typedef struct ngx_http_log_op_s ngx_http_log_op_t; |
13 | |
14 typedef u_char *(*ngx_http_log_op_run_pt) (ngx_http_request_t *r, u_char *buf, | |
15 ngx_http_log_op_t *op); | |
16 | |
17 typedef size_t (*ngx_http_log_op_getlen_pt) (ngx_http_request_t *r, | |
18 uintptr_t data); | |
19 | |
20 | |
21 struct ngx_http_log_op_s { | |
22 size_t len; | |
23 ngx_http_log_op_getlen_pt getlen; | |
24 ngx_http_log_op_run_pt run; | |
25 uintptr_t data; | |
26 }; | |
27 | |
573 | 28 |
29 typedef struct { | |
30 ngx_str_t name; | |
2261 | 31 ngx_array_t *flushes; |
573 | 32 ngx_array_t *ops; /* array of ngx_http_log_op_t */ |
33 } ngx_http_log_fmt_t; | |
34 | |
657 | 35 |
573 | 36 typedef struct { |
37 ngx_array_t formats; /* array of ngx_http_log_fmt_t */ | |
38 ngx_uint_t combined_used; /* unsigned combined_used:1 */ | |
39 } ngx_http_log_main_conf_t; | |
40 | |
657 | 41 |
573 | 42 typedef struct { |
2072 | 43 ngx_array_t *lengths; |
44 ngx_array_t *values; | |
45 } ngx_http_log_script_t; | |
46 | |
47 | |
48 typedef struct { | |
573 | 49 ngx_open_file_t *file; |
2072 | 50 ngx_http_log_script_t *script; |
633 | 51 time_t disk_full_time; |
1071
bd4202f92581
log a failure of the writing to access_log once per minute
Igor Sysoev <igor@sysoev.ru>
parents:
905
diff
changeset
|
52 time_t error_log_time; |
2261 | 53 ngx_http_log_fmt_t *format; |
573 | 54 } ngx_http_log_t; |
55 | |
657 | 56 |
573 | 57 typedef struct { |
58 ngx_array_t *logs; /* array of ngx_http_log_t */ | |
2072 | 59 |
60 ngx_open_file_cache_t *open_file_cache; | |
61 time_t open_file_cache_valid; | |
62 ngx_uint_t open_file_cache_min_uses; | |
63 | |
573 | 64 ngx_uint_t off; /* unsigned off:1 */ |
65 } ngx_http_log_loc_conf_t; | |
66 | |
67 | |
68 typedef struct { | |
69 ngx_str_t name; | |
70 size_t len; | |
71 ngx_http_log_op_run_pt run; | |
72 } ngx_http_log_var_t; | |
73 | |
74 | |
1071
bd4202f92581
log a failure of the writing to access_log once per minute
Igor Sysoev <igor@sysoev.ru>
parents:
905
diff
changeset
|
75 static void ngx_http_log_write(ngx_http_request_t *r, ngx_http_log_t *log, |
bd4202f92581
log a failure of the writing to access_log once per minute
Igor Sysoev <igor@sysoev.ru>
parents:
905
diff
changeset
|
76 u_char *buf, size_t len); |
2072 | 77 static ssize_t ngx_http_log_script_write(ngx_http_request_t *r, |
78 ngx_http_log_script_t *script, u_char **name, u_char *buf, size_t len); | |
1071
bd4202f92581
log a failure of the writing to access_log once per minute
Igor Sysoev <igor@sysoev.ru>
parents:
905
diff
changeset
|
79 |
290
87e73f067470
nginx-0.0.2-2004-03-16-10:10:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
282
diff
changeset
|
80 static u_char *ngx_http_log_connection(ngx_http_request_t *r, u_char *buf, |
497 | 81 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
|
82 static u_char *ngx_http_log_pipe(ngx_http_request_t *r, u_char *buf, |
497 | 83 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
|
84 static u_char *ngx_http_log_time(ngx_http_request_t *r, u_char *buf, |
497 | 85 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
|
86 static u_char *ngx_http_log_msec(ngx_http_request_t *r, u_char *buf, |
497 | 87 ngx_http_log_op_t *op); |
88 static u_char *ngx_http_log_request_time(ngx_http_request_t *r, u_char *buf, | |
89 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
|
90 static u_char *ngx_http_log_status(ngx_http_request_t *r, u_char *buf, |
497 | 91 ngx_http_log_op_t *op); |
573 | 92 static u_char *ngx_http_log_bytes_sent(ngx_http_request_t *r, u_char *buf, |
497 | 93 ngx_http_log_op_t *op); |
577 | 94 static u_char *ngx_http_log_body_bytes_sent(ngx_http_request_t *r, |
573 | 95 u_char *buf, ngx_http_log_op_t *op); |
475 | 96 static u_char *ngx_http_log_request_length(ngx_http_request_t *r, u_char *buf, |
497 | 97 ngx_http_log_op_t *op); |
479 | 98 |
501 | 99 static ngx_int_t ngx_http_log_variable_compile(ngx_conf_t *cf, |
100 ngx_http_log_op_t *op, ngx_str_t *value); | |
101 static size_t ngx_http_log_variable_getlen(ngx_http_request_t *r, | |
102 uintptr_t data); | |
103 static u_char *ngx_http_log_variable(ngx_http_request_t *r, u_char *buf, | |
104 ngx_http_log_op_t *op); | |
2008
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
105 static uintptr_t ngx_http_log_escape(u_char *dst, u_char *src, size_t size); |
501 | 106 |
107 | |
176
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_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
|
109 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
|
110 static char *ngx_http_log_merge_loc_conf(ngx_conf_t *cf, void *parent, |
497 | 111 void *child); |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
112 static char *ngx_http_log_set_log(ngx_conf_t *cf, ngx_command_t *cmd, |
497 | 113 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
|
114 static char *ngx_http_log_set_format(ngx_conf_t *cf, ngx_command_t *cmd, |
497 | 115 void *conf); |
573 | 116 static char *ngx_http_log_compile_format(ngx_conf_t *cf, |
2261 | 117 ngx_array_t *flushes, ngx_array_t *ops, ngx_array_t *args, ngx_uint_t s); |
2072 | 118 static char *ngx_http_log_open_file_cache(ngx_conf_t *cf, ngx_command_t *cmd, |
119 void *conf); | |
573 | 120 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
|
121 |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
122 |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
123 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
|
124 |
497 | 125 { ngx_string("log_format"), |
126 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_2MORE, | |
127 ngx_http_log_set_format, | |
128 NGX_HTTP_MAIN_CONF_OFFSET, | |
129 0, | |
130 NULL }, | |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
131 |
497 | 132 { ngx_string("access_log"), |
645 | 133 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_HTTP_LIF_CONF |
1562
bb662e047a21
allow access_log inside limit_except
Igor Sysoev <igor@sysoev.ru>
parents:
1271
diff
changeset
|
134 |NGX_HTTP_LMT_CONF|NGX_CONF_TAKE123, |
497 | 135 ngx_http_log_set_log, |
136 NGX_HTTP_LOC_CONF_OFFSET, | |
137 0, | |
138 NULL }, | |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
139 |
2072 | 140 { ngx_string("open_log_file_cache"), |
141 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1234, | |
142 ngx_http_log_open_file_cache, | |
143 NGX_HTTP_LOC_CONF_OFFSET, | |
144 0, | |
145 NULL }, | |
146 | |
497 | 147 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
|
148 }; |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
149 |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
150 |
667 | 151 static ngx_http_module_t ngx_http_log_module_ctx = { |
880 | 152 NULL, /* preconfiguration */ |
573 | 153 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
|
154 |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
155 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
|
156 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
|
157 |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
158 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
|
159 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
|
160 |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
161 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
|
162 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
|
163 }; |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
164 |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
165 |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
166 ngx_module_t ngx_http_log_module = { |
509 | 167 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
|
168 &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
|
169 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
|
170 NGX_HTTP_MODULE, /* module type */ |
541 | 171 NULL, /* init master */ |
573 | 172 NULL, /* init module */ |
541 | 173 NULL, /* init process */ |
174 NULL, /* init thread */ | |
175 NULL, /* exit thread */ | |
176 NULL, /* exit process */ | |
177 NULL, /* exit master */ | |
178 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
|
179 }; |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
180 |
26
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
181 |
1074 | 182 static ngx_str_t ngx_http_access_log = ngx_string(NGX_HTTP_LOG_PATH); |
573 | 183 |
184 | |
185 static ngx_str_t ngx_http_combined_fmt = | |
581 | 186 ngx_string("$remote_addr - $remote_user [$time_local] " |
577 | 187 "\"$request\" $status $body_bytes_sent " |
573 | 188 "\"$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
|
189 |
26
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
190 |
573 | 191 static ngx_http_log_var_t ngx_http_log_vars[] = { |
192 { ngx_string("connection"), NGX_ATOMIC_T_LEN, ngx_http_log_connection }, | |
193 { ngx_string("pipe"), 1, ngx_http_log_pipe }, | |
581 | 194 { ngx_string("time_local"), sizeof("28/Sep/1970:12:00:00 +0600") - 1, |
573 | 195 ngx_http_log_time }, |
196 { ngx_string("msec"), NGX_TIME_T_LEN + 4, ngx_http_log_msec }, | |
1179
6e2216ad2c87
$request_time has millisecond precision
Igor Sysoev <igor@sysoev.ru>
parents:
1161
diff
changeset
|
197 { ngx_string("request_time"), NGX_TIME_T_LEN + 4, |
6e2216ad2c87
$request_time has millisecond precision
Igor Sysoev <igor@sysoev.ru>
parents:
1161
diff
changeset
|
198 ngx_http_log_request_time }, |
573 | 199 { ngx_string("status"), 3, ngx_http_log_status }, |
200 { ngx_string("bytes_sent"), NGX_OFF_T_LEN, ngx_http_log_bytes_sent }, | |
577 | 201 { ngx_string("body_bytes_sent"), NGX_OFF_T_LEN, |
202 ngx_http_log_body_bytes_sent }, | |
573 | 203 { ngx_string("apache_bytes_sent"), NGX_OFF_T_LEN, |
577 | 204 ngx_http_log_body_bytes_sent }, |
573 | 205 { ngx_string("request_length"), NGX_SIZE_T_LEN, |
206 ngx_http_log_request_length }, | |
207 | |
208 { ngx_null_string, 0, NULL } | |
209 }; | |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
210 |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
211 |
497 | 212 ngx_int_t |
213 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
|
214 { |
290
87e73f067470
nginx-0.0.2-2004-03-16-10:10:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
282
diff
changeset
|
215 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
|
216 size_t len; |
1071
bd4202f92581
log a failure of the writing to access_log once per minute
Igor Sysoev <igor@sysoev.ru>
parents:
905
diff
changeset
|
217 ngx_uint_t i, l; |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
218 ngx_http_log_t *log; |
571 | 219 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
|
220 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
|
221 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
|
222 |
210
00cafae0bdf1
nginx-0.0.1-2003-12-14-23:10:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
208
diff
changeset
|
223 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
|
224 "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
|
225 |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
226 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
|
227 |
427
0d08eabe5c7b
nginx-0.0.10-2004-09-15-20:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
228 if (lcf->off) { |
0d08eabe5c7b
nginx-0.0.10-2004-09-15-20:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
229 return NGX_OK; |
0d08eabe5c7b
nginx-0.0.10-2004-09-15-20:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
230 } |
0d08eabe5c7b
nginx-0.0.10-2004-09-15-20:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
231 |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
232 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
|
233 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
|
234 |
633 | 235 if (ngx_time() == log[l].disk_full_time) { |
236 | |
237 /* | |
1071
bd4202f92581
log a failure of the writing to access_log once per minute
Igor Sysoev <igor@sysoev.ru>
parents:
905
diff
changeset
|
238 * on FreeBSD writing to a full filesystem with enabled softupdates |
633 | 239 * may block process for much longer time than writing to non-full |
1071
bd4202f92581
log a failure of the writing to access_log once per minute
Igor Sysoev <igor@sysoev.ru>
parents:
905
diff
changeset
|
240 * filesystem, so we skip writing to a log for one second |
633 | 241 */ |
242 | |
243 continue; | |
244 } | |
245 | |
2261 | 246 ngx_http_script_flush_no_cacheable_variables(r, log[l].format->flushes); |
247 | |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
248 len = 0; |
2261 | 249 op = log[l].format->ops->elts; |
250 for (i = 0; i < log[l].format->ops->nelts; 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
|
251 if (op[i].len == 0) { |
479 | 252 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
|
253 |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
254 } else { |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
255 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
|
256 } |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
257 } |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
258 |
571 | 259 len += NGX_LINEFEED_SIZE; |
260 | |
261 file = log[l].file; | |
262 | |
2072 | 263 if (file && file->buffer) { |
571 | 264 |
265 if (len > (size_t) (file->last - file->pos)) { | |
266 | |
1071
bd4202f92581
log a failure of the writing to access_log once per minute
Igor Sysoev <igor@sysoev.ru>
parents:
905
diff
changeset
|
267 ngx_http_log_write(r, &log[l], file->buffer, |
bd4202f92581
log a failure of the writing to access_log once per minute
Igor Sysoev <igor@sysoev.ru>
parents:
905
diff
changeset
|
268 file->pos - file->buffer); |
571 | 269 |
270 file->pos = file->buffer; | |
271 } | |
272 | |
273 if (len <= (size_t) (file->last - file->pos)) { | |
274 | |
275 p = file->pos; | |
276 | |
2261 | 277 for (i = 0; i < log[l].format->ops->nelts; i++) { |
571 | 278 p = op[i].run(r, p, &op[i]); |
279 } | |
280 | |
281 ngx_linefeed(p); | |
282 | |
283 file->pos = p; | |
284 | |
285 continue; | |
286 } | |
287 } | |
26
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
288 |
2049 | 289 line = ngx_pnalloc(r->pool, len); |
501 | 290 if (line == NULL) { |
473 | 291 return NGX_ERROR; |
292 } | |
293 | |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
294 p = line; |
26
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
295 |
2261 | 296 for (i = 0; i < log[l].format->ops->nelts; i++) { |
479 | 297 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
|
298 } |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
299 |
571 | 300 ngx_linefeed(p); |
301 | |
1071
bd4202f92581
log a failure of the writing to access_log once per minute
Igor Sysoev <igor@sysoev.ru>
parents:
905
diff
changeset
|
302 ngx_http_log_write(r, &log[l], 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
|
303 } |
26
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
304 |
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
305 return NGX_OK; |
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
306 } |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
307 |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
308 |
1071
bd4202f92581
log a failure of the writing to access_log once per minute
Igor Sysoev <igor@sysoev.ru>
parents:
905
diff
changeset
|
309 static void |
bd4202f92581
log a failure of the writing to access_log once per minute
Igor Sysoev <igor@sysoev.ru>
parents:
905
diff
changeset
|
310 ngx_http_log_write(ngx_http_request_t *r, ngx_http_log_t *log, u_char *buf, |
bd4202f92581
log a failure of the writing to access_log once per minute
Igor Sysoev <igor@sysoev.ru>
parents:
905
diff
changeset
|
311 size_t len) |
bd4202f92581
log a failure of the writing to access_log once per minute
Igor Sysoev <igor@sysoev.ru>
parents:
905
diff
changeset
|
312 { |
2072 | 313 u_char *name; |
314 time_t now; | |
315 ssize_t n; | |
316 ngx_err_t err; | |
1071
bd4202f92581
log a failure of the writing to access_log once per minute
Igor Sysoev <igor@sysoev.ru>
parents:
905
diff
changeset
|
317 |
2072 | 318 if (log->script == NULL) { |
319 name = log->file->name.data; | |
320 n = ngx_write_fd(log->file->fd, buf, len); | |
321 | |
322 } else { | |
323 name = NULL; | |
324 n = ngx_http_log_script_write(r, log->script, &name, buf, len); | |
325 } | |
1071
bd4202f92581
log a failure of the writing to access_log once per minute
Igor Sysoev <igor@sysoev.ru>
parents:
905
diff
changeset
|
326 |
bd4202f92581
log a failure of the writing to access_log once per minute
Igor Sysoev <igor@sysoev.ru>
parents:
905
diff
changeset
|
327 if (n == (ssize_t) len) { |
bd4202f92581
log a failure of the writing to access_log once per minute
Igor Sysoev <igor@sysoev.ru>
parents:
905
diff
changeset
|
328 return; |
bd4202f92581
log a failure of the writing to access_log once per minute
Igor Sysoev <igor@sysoev.ru>
parents:
905
diff
changeset
|
329 } |
bd4202f92581
log a failure of the writing to access_log once per minute
Igor Sysoev <igor@sysoev.ru>
parents:
905
diff
changeset
|
330 |
bd4202f92581
log a failure of the writing to access_log once per minute
Igor Sysoev <igor@sysoev.ru>
parents:
905
diff
changeset
|
331 now = ngx_time(); |
bd4202f92581
log a failure of the writing to access_log once per minute
Igor Sysoev <igor@sysoev.ru>
parents:
905
diff
changeset
|
332 |
bd4202f92581
log a failure of the writing to access_log once per minute
Igor Sysoev <igor@sysoev.ru>
parents:
905
diff
changeset
|
333 if (n == -1) { |
bd4202f92581
log a failure of the writing to access_log once per minute
Igor Sysoev <igor@sysoev.ru>
parents:
905
diff
changeset
|
334 err = ngx_errno; |
bd4202f92581
log a failure of the writing to access_log once per minute
Igor Sysoev <igor@sysoev.ru>
parents:
905
diff
changeset
|
335 |
bd4202f92581
log a failure of the writing to access_log once per minute
Igor Sysoev <igor@sysoev.ru>
parents:
905
diff
changeset
|
336 if (err == NGX_ENOSPC) { |
bd4202f92581
log a failure of the writing to access_log once per minute
Igor Sysoev <igor@sysoev.ru>
parents:
905
diff
changeset
|
337 log->disk_full_time = now; |
bd4202f92581
log a failure of the writing to access_log once per minute
Igor Sysoev <igor@sysoev.ru>
parents:
905
diff
changeset
|
338 } |
bd4202f92581
log a failure of the writing to access_log once per minute
Igor Sysoev <igor@sysoev.ru>
parents:
905
diff
changeset
|
339 |
1161
6002e0253221
use 60 seconds interval but not 61 seconds
Igor Sysoev <igor@sysoev.ru>
parents:
1074
diff
changeset
|
340 if (now - log->error_log_time > 59) { |
1071
bd4202f92581
log a failure of the writing to access_log once per minute
Igor Sysoev <igor@sysoev.ru>
parents:
905
diff
changeset
|
341 ngx_log_error(NGX_LOG_ALERT, r->connection->log, err, |
2072 | 342 ngx_write_fd_n " to \"%s\" failed", name); |
1071
bd4202f92581
log a failure of the writing to access_log once per minute
Igor Sysoev <igor@sysoev.ru>
parents:
905
diff
changeset
|
343 |
bd4202f92581
log a failure of the writing to access_log once per minute
Igor Sysoev <igor@sysoev.ru>
parents:
905
diff
changeset
|
344 log->error_log_time = now; |
bd4202f92581
log a failure of the writing to access_log once per minute
Igor Sysoev <igor@sysoev.ru>
parents:
905
diff
changeset
|
345 } |
bd4202f92581
log a failure of the writing to access_log once per minute
Igor Sysoev <igor@sysoev.ru>
parents:
905
diff
changeset
|
346 |
bd4202f92581
log a failure of the writing to access_log once per minute
Igor Sysoev <igor@sysoev.ru>
parents:
905
diff
changeset
|
347 return; |
bd4202f92581
log a failure of the writing to access_log once per minute
Igor Sysoev <igor@sysoev.ru>
parents:
905
diff
changeset
|
348 } |
bd4202f92581
log a failure of the writing to access_log once per minute
Igor Sysoev <igor@sysoev.ru>
parents:
905
diff
changeset
|
349 |
1161
6002e0253221
use 60 seconds interval but not 61 seconds
Igor Sysoev <igor@sysoev.ru>
parents:
1074
diff
changeset
|
350 if (now - log->error_log_time > 59) { |
1071
bd4202f92581
log a failure of the writing to access_log once per minute
Igor Sysoev <igor@sysoev.ru>
parents:
905
diff
changeset
|
351 ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0, |
2072 | 352 ngx_write_fd_n " to \"%s\" was incomplete: %z of %uz", |
353 name, n, len); | |
1071
bd4202f92581
log a failure of the writing to access_log once per minute
Igor Sysoev <igor@sysoev.ru>
parents:
905
diff
changeset
|
354 |
bd4202f92581
log a failure of the writing to access_log once per minute
Igor Sysoev <igor@sysoev.ru>
parents:
905
diff
changeset
|
355 log->error_log_time = now; |
bd4202f92581
log a failure of the writing to access_log once per minute
Igor Sysoev <igor@sysoev.ru>
parents:
905
diff
changeset
|
356 } |
bd4202f92581
log a failure of the writing to access_log once per minute
Igor Sysoev <igor@sysoev.ru>
parents:
905
diff
changeset
|
357 } |
bd4202f92581
log a failure of the writing to access_log once per minute
Igor Sysoev <igor@sysoev.ru>
parents:
905
diff
changeset
|
358 |
bd4202f92581
log a failure of the writing to access_log once per minute
Igor Sysoev <igor@sysoev.ru>
parents:
905
diff
changeset
|
359 |
2072 | 360 static ssize_t |
361 ngx_http_log_script_write(ngx_http_request_t *r, ngx_http_log_script_t *script, | |
362 u_char **name, u_char *buf, size_t len) | |
363 { | |
364 size_t root; | |
365 ssize_t n; | |
366 ngx_str_t log, path; | |
367 ngx_open_file_info_t of; | |
368 ngx_http_log_loc_conf_t *llcf; | |
369 ngx_http_core_loc_conf_t *clcf; | |
370 | |
2087
c8039b26a949
always test root existence for access_log with variables
Igor Sysoev <igor@sysoev.ru>
parents:
2080
diff
changeset
|
371 if (!r->root_tested) { |
2072 | 372 |
373 /* test root directory existance */ | |
374 | |
375 if (ngx_http_map_uri_to_path(r, &path, &root, 0) == NULL) { | |
376 /* simulate successfull logging */ | |
377 return len; | |
378 } | |
379 | |
380 path.data[root] = '\0'; | |
381 | |
382 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); | |
383 | |
384 ngx_memzero(&of, sizeof(ngx_open_file_info_t)); | |
385 | |
386 of.valid = clcf->open_file_cache_valid; | |
387 of.min_uses = clcf->open_file_cache_min_uses; | |
2756
09cab3f8d92e
*) of.test_only to not open file if only stat() is enough
Igor Sysoev <igor@sysoev.ru>
parents:
2536
diff
changeset
|
388 of.test_dir = 1; |
09cab3f8d92e
*) of.test_only to not open file if only stat() is enough
Igor Sysoev <igor@sysoev.ru>
parents:
2536
diff
changeset
|
389 of.test_only = 1; |
2072 | 390 of.errors = clcf->open_file_cache_errors; |
391 of.events = clcf->open_file_cache_events; | |
392 | |
393 if (ngx_open_cached_file(clcf->open_file_cache, &path, &of, r->pool) | |
2087
c8039b26a949
always test root existence for access_log with variables
Igor Sysoev <igor@sysoev.ru>
parents:
2080
diff
changeset
|
394 != NGX_OK) |
2072 | 395 { |
2087
c8039b26a949
always test root existence for access_log with variables
Igor Sysoev <igor@sysoev.ru>
parents:
2080
diff
changeset
|
396 if (of.err == 0) { |
c8039b26a949
always test root existence for access_log with variables
Igor Sysoev <igor@sysoev.ru>
parents:
2080
diff
changeset
|
397 /* simulate successfull logging */ |
c8039b26a949
always test root existence for access_log with variables
Igor Sysoev <igor@sysoev.ru>
parents:
2080
diff
changeset
|
398 return len; |
c8039b26a949
always test root existence for access_log with variables
Igor Sysoev <igor@sysoev.ru>
parents:
2080
diff
changeset
|
399 } |
c8039b26a949
always test root existence for access_log with variables
Igor Sysoev <igor@sysoev.ru>
parents:
2080
diff
changeset
|
400 |
c8039b26a949
always test root existence for access_log with variables
Igor Sysoev <igor@sysoev.ru>
parents:
2080
diff
changeset
|
401 ngx_log_error(NGX_LOG_ERR, r->connection->log, of.err, |
c8039b26a949
always test root existence for access_log with variables
Igor Sysoev <igor@sysoev.ru>
parents:
2080
diff
changeset
|
402 "testing \"%s\" existence failed", path.data); |
c8039b26a949
always test root existence for access_log with variables
Igor Sysoev <igor@sysoev.ru>
parents:
2080
diff
changeset
|
403 |
c8039b26a949
always test root existence for access_log with variables
Igor Sysoev <igor@sysoev.ru>
parents:
2080
diff
changeset
|
404 /* simulate successfull logging */ |
c8039b26a949
always test root existence for access_log with variables
Igor Sysoev <igor@sysoev.ru>
parents:
2080
diff
changeset
|
405 return len; |
c8039b26a949
always test root existence for access_log with variables
Igor Sysoev <igor@sysoev.ru>
parents:
2080
diff
changeset
|
406 } |
c8039b26a949
always test root existence for access_log with variables
Igor Sysoev <igor@sysoev.ru>
parents:
2080
diff
changeset
|
407 |
c8039b26a949
always test root existence for access_log with variables
Igor Sysoev <igor@sysoev.ru>
parents:
2080
diff
changeset
|
408 if (!of.is_dir) { |
c8039b26a949
always test root existence for access_log with variables
Igor Sysoev <igor@sysoev.ru>
parents:
2080
diff
changeset
|
409 ngx_log_error(NGX_LOG_ERR, r->connection->log, NGX_ENOTDIR, |
c8039b26a949
always test root existence for access_log with variables
Igor Sysoev <igor@sysoev.ru>
parents:
2080
diff
changeset
|
410 "testing \"%s\" existence failed", path.data); |
c8039b26a949
always test root existence for access_log with variables
Igor Sysoev <igor@sysoev.ru>
parents:
2080
diff
changeset
|
411 |
c8039b26a949
always test root existence for access_log with variables
Igor Sysoev <igor@sysoev.ru>
parents:
2080
diff
changeset
|
412 /* simulate successfull logging */ |
2072 | 413 return len; |
414 } | |
415 } | |
416 | |
417 if (ngx_http_script_run(r, &log, script->lengths->elts, 1, | |
418 script->values->elts) | |
419 == NULL) | |
420 { | |
421 /* simulate successfull logging */ | |
422 return len; | |
423 } | |
424 | |
425 log.data[log.len - 1] = '\0'; | |
426 *name = log.data; | |
427 | |
428 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | |
429 "http log \"%s\"", log.data); | |
430 | |
431 llcf = ngx_http_get_module_loc_conf(r, ngx_http_log_module); | |
432 | |
433 ngx_memzero(&of, sizeof(ngx_open_file_info_t)); | |
434 | |
435 of.log = 1; | |
436 of.valid = llcf->open_file_cache_valid; | |
437 of.min_uses = llcf->open_file_cache_min_uses; | |
2277 | 438 of.directio = NGX_OPEN_FILE_DIRECTIO_OFF; |
2072 | 439 |
440 if (ngx_open_cached_file(llcf->open_file_cache, &log, &of, r->pool) | |
441 != NGX_OK) | |
442 { | |
443 ngx_log_error(NGX_LOG_CRIT, r->connection->log, ngx_errno, | |
2756
09cab3f8d92e
*) of.test_only to not open file if only stat() is enough
Igor Sysoev <igor@sysoev.ru>
parents:
2536
diff
changeset
|
444 "%s \"%s\" failed", of.failed, log.data); |
2077 | 445 /* simulate successfull logging */ |
446 return len; | |
2072 | 447 } |
448 | |
449 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | |
450 "http log #%d", of.fd); | |
451 | |
452 n = ngx_write_fd(of.fd, buf, len); | |
453 | |
454 return n; | |
455 } | |
456 | |
457 | |
497 | 458 static u_char * |
459 ngx_http_log_copy_short(ngx_http_request_t *r, u_char *buf, | |
460 ngx_http_log_op_t *op) | |
479 | 461 { |
462 size_t len; | |
463 uintptr_t data; | |
464 | |
465 len = op->len; | |
466 data = op->data; | |
467 | |
468 while (len--) { | |
469 *buf++ = (u_char) (data & 0xff); | |
470 data >>= 8; | |
471 } | |
472 | |
473 return buf; | |
474 } | |
475 | |
476 | |
497 | 477 static u_char * |
478 ngx_http_log_copy_long(ngx_http_request_t *r, u_char *buf, | |
479 ngx_http_log_op_t *op) | |
479 | 480 { |
481 return ngx_cpymem(buf, (u_char *) op->data, op->len); | |
482 } | |
483 | |
484 | |
497 | 485 static u_char * |
486 ngx_http_log_connection(ngx_http_request_t *r, u_char *buf, | |
487 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
|
488 { |
455 | 489 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
|
490 } |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
491 |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
492 |
497 | 493 static u_char * |
494 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
|
495 { |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
496 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
|
497 *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
|
498 } else { |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
499 *buf = '.'; |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
500 } |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
501 |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
502 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
|
503 } |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
504 |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
505 |
497 | 506 static u_char * |
507 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
|
508 { |
178
a8ff48d26cca
nginx-0.0.1-2003-11-11-00:09:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
177
diff
changeset
|
509 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
|
510 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
|
511 } |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
512 |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
513 |
497 | 514 static u_char * |
515 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
|
516 { |
563 | 517 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
|
518 |
563 | 519 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
|
520 |
563 | 521 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
|
522 } |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
393
diff
changeset
|
523 |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
393
diff
changeset
|
524 |
497 | 525 static u_char * |
526 ngx_http_log_request_time(ngx_http_request_t *r, u_char *buf, | |
527 ngx_http_log_op_t *op) | |
528 { | |
1179
6e2216ad2c87
$request_time has millisecond precision
Igor Sysoev <igor@sysoev.ru>
parents:
1161
diff
changeset
|
529 ngx_time_t *tp; |
6e2216ad2c87
$request_time has millisecond precision
Igor Sysoev <igor@sysoev.ru>
parents:
1161
diff
changeset
|
530 ngx_msec_int_t ms; |
6e2216ad2c87
$request_time has millisecond precision
Igor Sysoev <igor@sysoev.ru>
parents:
1161
diff
changeset
|
531 |
6e2216ad2c87
$request_time has millisecond precision
Igor Sysoev <igor@sysoev.ru>
parents:
1161
diff
changeset
|
532 tp = ngx_timeofday(); |
497 | 533 |
1640 | 534 ms = (ngx_msec_int_t) |
535 ((tp->sec - r->start_sec) * 1000 + (tp->msec - r->start_msec)); | |
1179
6e2216ad2c87
$request_time has millisecond precision
Igor Sysoev <igor@sysoev.ru>
parents:
1161
diff
changeset
|
536 ms = (ms >= 0) ? ms : 0; |
497 | 537 |
1179
6e2216ad2c87
$request_time has millisecond precision
Igor Sysoev <igor@sysoev.ru>
parents:
1161
diff
changeset
|
538 return ngx_sprintf(buf, "%T.%03M", ms / 1000, ms % 1000); |
497 | 539 } |
540 | |
541 | |
542 static u_char * | |
543 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
|
544 { |
3439
3354dfba9da4
merge r3137, r3198, r3199, r3353, r3370, r3371, r3398, r3399:
Igor Sysoev <igor@sysoev.ru>
parents:
3426
diff
changeset
|
545 ngx_uint_t status; |
3354dfba9da4
merge r3137, r3198, r3199, r3353, r3370, r3371, r3398, r3399:
Igor Sysoev <igor@sysoev.ru>
parents:
3426
diff
changeset
|
546 |
3354dfba9da4
merge r3137, r3198, r3199, r3353, r3370, r3371, r3398, r3399:
Igor Sysoev <igor@sysoev.ru>
parents:
3426
diff
changeset
|
547 if (r->err_status) { |
3354dfba9da4
merge r3137, r3198, r3199, r3353, r3370, r3371, r3398, r3399:
Igor Sysoev <igor@sysoev.ru>
parents:
3426
diff
changeset
|
548 status = r->err_status; |
3354dfba9da4
merge r3137, r3198, r3199, r3353, r3370, r3371, r3398, r3399:
Igor Sysoev <igor@sysoev.ru>
parents:
3426
diff
changeset
|
549 |
3354dfba9da4
merge r3137, r3198, r3199, r3353, r3370, r3371, r3398, r3399:
Igor Sysoev <igor@sysoev.ru>
parents:
3426
diff
changeset
|
550 } else if (r->headers_out.status) { |
3354dfba9da4
merge r3137, r3198, r3199, r3353, r3370, r3371, r3398, r3399:
Igor Sysoev <igor@sysoev.ru>
parents:
3426
diff
changeset
|
551 status = r->headers_out.status; |
3354dfba9da4
merge r3137, r3198, r3199, r3353, r3370, r3371, r3398, r3399:
Igor Sysoev <igor@sysoev.ru>
parents:
3426
diff
changeset
|
552 |
3354dfba9da4
merge r3137, r3198, r3199, r3353, r3370, r3371, r3398, r3399:
Igor Sysoev <igor@sysoev.ru>
parents:
3426
diff
changeset
|
553 } else if (r->http_version == NGX_HTTP_VERSION_9) { |
3354dfba9da4
merge r3137, r3198, r3199, r3353, r3370, r3371, r3398, r3399:
Igor Sysoev <igor@sysoev.ru>
parents:
3426
diff
changeset
|
554 *buf++ = '0'; |
3354dfba9da4
merge r3137, r3198, r3199, r3353, r3370, r3371, r3398, r3399:
Igor Sysoev <igor@sysoev.ru>
parents:
3426
diff
changeset
|
555 *buf++ = '0'; |
3354dfba9da4
merge r3137, r3198, r3199, r3353, r3370, r3371, r3398, r3399:
Igor Sysoev <igor@sysoev.ru>
parents:
3426
diff
changeset
|
556 *buf++ = '9'; |
3354dfba9da4
merge r3137, r3198, r3199, r3353, r3370, r3371, r3398, r3399:
Igor Sysoev <igor@sysoev.ru>
parents:
3426
diff
changeset
|
557 return buf; |
3354dfba9da4
merge r3137, r3198, r3199, r3353, r3370, r3371, r3398, r3399:
Igor Sysoev <igor@sysoev.ru>
parents:
3426
diff
changeset
|
558 |
3354dfba9da4
merge r3137, r3198, r3199, r3353, r3370, r3371, r3398, r3399:
Igor Sysoev <igor@sysoev.ru>
parents:
3426
diff
changeset
|
559 } else { |
3354dfba9da4
merge r3137, r3198, r3199, r3353, r3370, r3371, r3398, r3399:
Igor Sysoev <igor@sysoev.ru>
parents:
3426
diff
changeset
|
560 status = 0; |
3354dfba9da4
merge r3137, r3198, r3199, r3353, r3370, r3371, r3398, r3399:
Igor Sysoev <igor@sysoev.ru>
parents:
3426
diff
changeset
|
561 } |
3354dfba9da4
merge r3137, r3198, r3199, r3353, r3370, r3371, r3398, r3399:
Igor Sysoev <igor@sysoev.ru>
parents:
3426
diff
changeset
|
562 |
3354dfba9da4
merge r3137, r3198, r3199, r3353, r3370, r3371, r3398, r3399:
Igor Sysoev <igor@sysoev.ru>
parents:
3426
diff
changeset
|
563 return ngx_sprintf(buf, "%ui", 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
|
564 } |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
565 |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
566 |
497 | 567 static u_char * |
573 | 568 ngx_http_log_bytes_sent(ngx_http_request_t *r, u_char *buf, |
569 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
|
570 { |
455 | 571 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
|
572 } |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
573 |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
574 |
1271 | 575 /* |
576 * although there is a real $body_bytes_sent variable, | |
577 * this log operation code function is more optimized for logging | |
578 */ | |
579 | |
497 | 580 static u_char * |
577 | 581 ngx_http_log_body_bytes_sent(ngx_http_request_t *r, u_char *buf, |
497 | 582 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
|
583 { |
497 | 584 off_t length; |
585 | |
586 length = r->connection->sent - r->header_size; | |
587 | |
588 if (length > 0) { | |
589 return ngx_sprintf(buf, "%O", length); | |
590 } | |
591 | |
592 *buf = '0'; | |
593 | |
594 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
|
595 } |
00cafae0bdf1
nginx-0.0.1-2003-12-14-23:10:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
208
diff
changeset
|
596 |
00cafae0bdf1
nginx-0.0.1-2003-12-14-23:10:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
208
diff
changeset
|
597 |
497 | 598 static u_char * |
599 ngx_http_log_request_length(ngx_http_request_t *r, u_char *buf, | |
600 ngx_http_log_op_t *op) | |
475 | 601 { |
663 | 602 return ngx_sprintf(buf, "%O", r->request_length); |
475 | 603 } |
604 | |
605 | |
497 | 606 static ngx_int_t |
501 | 607 ngx_http_log_variable_compile(ngx_conf_t *cf, ngx_http_log_op_t *op, |
608 ngx_str_t *value) | |
609 { | |
509 | 610 ngx_int_t index; |
501 | 611 |
509 | 612 index = ngx_http_get_variable_index(cf, value); |
613 if (index == NGX_ERROR) { | |
501 | 614 return NGX_ERROR; |
615 } | |
616 | |
617 op->len = 0; | |
618 op->getlen = ngx_http_log_variable_getlen; | |
619 op->run = ngx_http_log_variable; | |
509 | 620 op->data = index; |
501 | 621 |
622 return NGX_OK; | |
623 } | |
624 | |
625 | |
626 static size_t | |
627 ngx_http_log_variable_getlen(ngx_http_request_t *r, uintptr_t data) | |
628 { | |
2008
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
629 uintptr_t len; |
501 | 630 ngx_http_variable_value_t *value; |
631 | |
632 value = ngx_http_get_indexed_variable(r, data); | |
633 | |
573 | 634 if (value == NULL || value->not_found) { |
501 | 635 return 1; |
636 } | |
637 | |
2008
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
638 len = ngx_http_log_escape(NULL, value->data, value->len); |
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
639 |
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
640 value->escape = len ? 1 : 0; |
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
641 |
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
642 return value->len + len * 3; |
501 | 643 } |
644 | |
645 | |
646 static u_char * | |
647 ngx_http_log_variable(ngx_http_request_t *r, u_char *buf, ngx_http_log_op_t *op) | |
648 { | |
649 ngx_http_variable_value_t *value; | |
650 | |
651 value = ngx_http_get_indexed_variable(r, op->data); | |
652 | |
573 | 653 if (value == NULL || value->not_found) { |
501 | 654 *buf = '-'; |
655 return buf + 1; | |
656 } | |
657 | |
2008
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
658 if (value->escape == 0) { |
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
659 return ngx_cpymem(buf, value->data, value->len); |
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
660 |
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
661 } else { |
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
662 return (u_char *) ngx_http_log_escape(buf, value->data, value->len); |
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
663 } |
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
664 } |
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
665 |
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
666 |
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
667 static uintptr_t |
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
668 ngx_http_log_escape(u_char *dst, u_char *src, size_t size) |
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
669 { |
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
670 ngx_uint_t i, n; |
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
671 static u_char hex[] = "0123456789ABCDEF"; |
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
672 |
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
673 static uint32_t escape[] = { |
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
674 0xffffffff, /* 1111 1111 1111 1111 1111 1111 1111 1111 */ |
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
675 |
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
676 /* ?>=< ;:98 7654 3210 /.-, +*)( '&%$ #"! */ |
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
677 0x00000004, /* 0000 0000 0000 0000 0000 0000 0000 0100 */ |
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
678 |
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
679 /* _^]\ [ZYX WVUT SRQP ONML KJIH GFED CBA@ */ |
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
680 0x10000000, /* 0001 0000 0000 0000 0000 0000 0000 0000 */ |
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
681 |
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
682 /* ~}| {zyx wvut srqp onml kjih gfed cba` */ |
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
683 0x00000000, /* 0000 0000 0000 0000 0000 0000 0000 0000 */ |
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
684 |
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
685 0x00000000, /* 0000 0000 0000 0000 0000 0000 0000 0000 */ |
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
686 0x00000000, /* 0000 0000 0000 0000 0000 0000 0000 0000 */ |
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
687 0x00000000, /* 0000 0000 0000 0000 0000 0000 0000 0000 */ |
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
688 0x00000000, /* 0000 0000 0000 0000 0000 0000 0000 0000 */ |
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
689 }; |
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
690 |
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
691 |
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
692 if (dst == NULL) { |
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
693 |
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
694 /* find the number of the characters to be escaped */ |
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
695 |
3238
415400fa0f10
merge r2920, r2934, r3116, r3119:
Igor Sysoev <igor@sysoev.ru>
parents:
3237
diff
changeset
|
696 n = 0; |
2008
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
697 |
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
698 for (i = 0; i < size; i++) { |
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
699 if (escape[*src >> 5] & (1 << (*src & 0x1f))) { |
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
700 n++; |
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
701 } |
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
702 src++; |
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
703 } |
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
704 |
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
705 return (uintptr_t) n; |
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
706 } |
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
707 |
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
708 for (i = 0; i < size; i++) { |
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
709 if (escape[*src >> 5] & (1 << (*src & 0x1f))) { |
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
710 *dst++ = '\\'; |
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
711 *dst++ = 'x'; |
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
712 *dst++ = hex[*src >> 4]; |
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
713 *dst++ = hex[*src & 0xf]; |
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
714 src++; |
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
715 |
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
716 } else { |
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
717 *dst++ = *src++; |
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
718 } |
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
719 } |
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
720 |
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
721 return (uintptr_t) dst; |
501 | 722 } |
723 | |
724 | |
497 | 725 static void * |
726 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
|
727 { |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
728 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
|
729 |
573 | 730 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
|
731 |
501 | 732 conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_log_main_conf_t)); |
733 if (conf == NULL) { | |
3237
2efa8d2fcde1
merge r2903, r2911, r2912, r3002:
Igor Sysoev <igor@sysoev.ru>
parents:
2756
diff
changeset
|
734 return 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
|
735 } |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
736 |
497 | 737 if (ngx_array_init(&conf->formats, cf->pool, 4, sizeof(ngx_http_log_fmt_t)) |
573 | 738 != NGX_OK) |
497 | 739 { |
3237
2efa8d2fcde1
merge r2903, r2911, r2912, r3002:
Igor Sysoev <igor@sysoev.ru>
parents:
2756
diff
changeset
|
740 return NULL; |
497 | 741 } |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
742 |
573 | 743 fmt = ngx_array_push(&conf->formats); |
744 if (fmt == NULL) { | |
3237
2efa8d2fcde1
merge r2903, r2911, r2912, r3002:
Igor Sysoev <igor@sysoev.ru>
parents:
2756
diff
changeset
|
745 return 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
|
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 |
573 | 748 fmt->name.len = sizeof("combined") - 1; |
749 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
|
750 |
2261 | 751 fmt->flushes = NULL; |
752 | |
573 | 753 fmt->ops = ngx_array_create(cf->pool, 16, sizeof(ngx_http_log_op_t)); |
754 if (fmt->ops == NULL) { | |
3237
2efa8d2fcde1
merge r2903, r2911, r2912, r3002:
Igor Sysoev <igor@sysoev.ru>
parents:
2756
diff
changeset
|
755 return 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
|
756 } |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
757 |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
758 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
|
759 } |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
760 |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
761 |
497 | 762 static void * |
763 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
|
764 { |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
765 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
|
766 |
501 | 767 conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_log_loc_conf_t)); |
768 if (conf == NULL) { | |
3237
2efa8d2fcde1
merge r2903, r2911, r2912, r3002:
Igor Sysoev <igor@sysoev.ru>
parents:
2756
diff
changeset
|
769 return NULL; |
427
0d08eabe5c7b
nginx-0.0.10-2004-09-15-20:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
770 } |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
771 |
2072 | 772 conf->open_file_cache = NGX_CONF_UNSET_PTR; |
773 | |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
774 return conf; |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
775 } |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
776 |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
777 |
497 | 778 static char * |
779 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
|
780 { |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
781 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
|
782 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
|
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 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
|
785 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
|
786 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
|
787 |
2072 | 788 if (conf->open_file_cache == NGX_CONF_UNSET_PTR) { |
789 | |
790 conf->open_file_cache = prev->open_file_cache; | |
791 conf->open_file_cache_valid = prev->open_file_cache_valid; | |
792 conf->open_file_cache_min_uses = prev->open_file_cache_min_uses; | |
793 | |
794 if (conf->open_file_cache == NGX_CONF_UNSET_PTR) { | |
795 conf->open_file_cache = NULL; | |
796 } | |
797 } | |
798 | |
1074 | 799 if (conf->logs || conf->off) { |
800 return NGX_CONF_OK; | |
801 } | |
427
0d08eabe5c7b
nginx-0.0.10-2004-09-15-20:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
802 |
2078
9acbc5e7bcbd
fix variable access_log merging
Igor Sysoev <igor@sysoev.ru>
parents:
2077
diff
changeset
|
803 conf->logs = prev->logs; |
9acbc5e7bcbd
fix variable access_log merging
Igor Sysoev <igor@sysoev.ru>
parents:
2077
diff
changeset
|
804 conf->off = prev->off; |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
805 |
1074 | 806 if (conf->logs || conf->off) { |
807 return NGX_CONF_OK; | |
808 } | |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
809 |
1074 | 810 conf->logs = ngx_array_create(cf->pool, 2, sizeof(ngx_http_log_t)); |
811 if (conf->logs == NULL) { | |
812 return NGX_CONF_ERROR; | |
813 } | |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
814 |
1074 | 815 log = ngx_array_push(conf->logs); |
816 if (log == NULL) { | |
817 return NGX_CONF_ERROR; | |
818 } | |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
819 |
1074 | 820 log->file = ngx_conf_open_file(cf->cycle, &ngx_http_access_log); |
821 if (log->file == NULL) { | |
822 return NGX_CONF_ERROR; | |
823 } | |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
824 |
2080
a24c7009de0b
NULL script in default access_log
Igor Sysoev <igor@sysoev.ru>
parents:
2078
diff
changeset
|
825 log->script = NULL; |
1074 | 826 log->disk_full_time = 0; |
827 log->error_log_time = 0; | |
427
0d08eabe5c7b
nginx-0.0.10-2004-09-15-20:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
828 |
1074 | 829 lmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_log_module); |
830 fmt = lmcf->formats.elts; | |
831 | |
832 /* the default "combined" format */ | |
2261 | 833 log->format = &fmt[0]; |
1074 | 834 lmcf->combined_used = 1; |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
835 |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
836 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
|
837 } |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
838 |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
839 |
497 | 840 static char * |
841 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
|
842 { |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
843 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
|
844 |
2072 | 845 ssize_t buf; |
846 ngx_uint_t i, n; | |
847 ngx_str_t *value, name; | |
848 ngx_http_log_t *log; | |
849 ngx_http_log_fmt_t *fmt; | |
850 ngx_http_log_main_conf_t *lmcf; | |
851 ngx_http_script_compile_t sc; | |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
852 |
427
0d08eabe5c7b
nginx-0.0.10-2004-09-15-20:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
853 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
|
854 |
0d08eabe5c7b
nginx-0.0.10-2004-09-15-20:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
855 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
|
856 llcf->off = 1; |
3426 | 857 if (cf->args->nelts == 2) { |
858 return NGX_CONF_OK; | |
859 } | |
860 | |
861 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
862 "invalid parameter \"%V\"", &value[2]); | |
863 return NGX_CONF_ERROR; | |
427
0d08eabe5c7b
nginx-0.0.10-2004-09-15-20:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
864 } |
0d08eabe5c7b
nginx-0.0.10-2004-09-15-20:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
865 |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
866 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
|
867 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
|
868 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
|
869 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
|
870 } |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
871 } |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
872 |
393
5659d773cfa8
nginx-0.0.7-2004-07-15-20:35:51 import
Igor Sysoev <igor@sysoev.ru>
parents:
356
diff
changeset
|
873 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
|
874 |
501 | 875 log = ngx_array_push(llcf->logs); |
876 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
|
877 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
|
878 } |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
879 |
2072 | 880 ngx_memzero(log, sizeof(ngx_http_log_t)); |
881 | |
882 n = ngx_http_script_variables_count(&value[1]); | |
883 | |
884 if (n == 0) { | |
885 log->file = ngx_conf_open_file(cf->cycle, &value[1]); | |
886 if (log->file == NULL) { | |
887 return NGX_CONF_ERROR; | |
888 } | |
889 | |
890 } else { | |
2536
a6d6d762c554
small optimization: " == NGX_ERROR" > " != NGX_OK"
Igor Sysoev <igor@sysoev.ru>
parents:
2277
diff
changeset
|
891 if (ngx_conf_full_name(cf->cycle, &value[1], 0) != NGX_OK) { |
2072 | 892 return NGX_CONF_ERROR; |
893 } | |
894 | |
895 log->script = ngx_pcalloc(cf->pool, sizeof(ngx_http_log_script_t)); | |
896 if (log->script == NULL) { | |
897 return NGX_CONF_ERROR; | |
898 } | |
899 | |
900 ngx_memzero(&sc, sizeof(ngx_http_script_compile_t)); | |
901 | |
902 sc.cf = cf; | |
903 sc.source = &value[1]; | |
904 sc.lengths = &log->script->lengths; | |
905 sc.values = &log->script->values; | |
906 sc.variables = n; | |
907 sc.complete_lengths = 1; | |
908 sc.complete_values = 1; | |
909 | |
910 if (ngx_http_script_compile(&sc) != NGX_OK) { | |
911 return NGX_CONF_ERROR; | |
912 } | |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
913 } |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
914 |
571 | 915 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
|
916 name = value[2]; |
581 | 917 |
918 if (ngx_strcmp(name.data, "combined") == 0) { | |
919 lmcf->combined_used = 1; | |
920 } | |
921 | |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
922 } else { |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
923 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
|
924 name.data = (u_char *) "combined"; |
573 | 925 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
|
926 } |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
927 |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
928 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
|
929 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
|
930 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
|
931 && 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
|
932 { |
2261 | 933 log->format = &fmt[i]; |
571 | 934 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
|
935 } |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
936 } |
100
7ebc8b7fb816
nginx-0.0.1-2003-06-03-19:42:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
99
diff
changeset
|
937 |
487 | 938 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
939 "unknown log format \"%V\"", &name); | |
571 | 940 return NGX_CONF_ERROR; |
487 | 941 |
571 | 942 buffer: |
943 | |
944 if (cf->args->nelts == 4) { | |
945 if (ngx_strncmp(value[3].data, "buffer=", 7) != 0) { | |
946 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
947 "invalid parameter \"%V\"", &value[3]); | |
948 return NGX_CONF_ERROR; | |
949 } | |
950 | |
2072 | 951 if (log->script) { |
952 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
953 "buffered logs can not have variables in name"); | |
954 return NGX_CONF_ERROR; | |
955 } | |
956 | |
571 | 957 name.len = value[3].len - 7; |
958 name.data = value[3].data + 7; | |
959 | |
960 buf = ngx_parse_size(&name); | |
961 | |
962 if (buf == NGX_ERROR) { | |
963 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
964 "invalid parameter \"%V\"", &value[3]); | |
965 return NGX_CONF_ERROR; | |
966 } | |
967 | |
968 if (log->file->buffer && log->file->last - log->file->pos != buf) { | |
969 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
970 "access_log \"%V\" already defined " | |
971 "with different buffer size", &value[1]); | |
972 return NGX_CONF_ERROR; | |
973 } | |
974 | |
975 log->file->buffer = ngx_palloc(cf->pool, buf); | |
976 if (log->file->buffer == NULL) { | |
977 return NGX_CONF_ERROR; | |
978 } | |
979 | |
980 log->file->pos = log->file->buffer; | |
981 log->file->last = log->file->buffer + buf; | |
982 } | |
983 | |
984 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
|
985 } |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
986 |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
987 |
497 | 988 static char * |
989 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
|
990 { |
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_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
|
992 |
573 | 993 ngx_str_t *value; |
994 ngx_uint_t i; | |
995 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
|
996 |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
997 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
|
998 |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
999 fmt = lmcf->formats.elts; |
573 | 1000 for (i = 0; i < lmcf->formats.nelts; i++) { |
1001 if (fmt[i].name.len == value[1].len | |
1002 && 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
|
1003 { |
2036 | 1004 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
1005 "duplicate \"log_format\" name \"%V\"", | |
1006 &value[1]); | |
1007 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
|
1008 } |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1009 } |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1010 |
501 | 1011 fmt = ngx_array_push(&lmcf->formats); |
1012 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
|
1013 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
|
1014 } |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1015 |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1016 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
|
1017 |
2261 | 1018 fmt->flushes = ngx_array_create(cf->pool, 4, sizeof(ngx_int_t)); |
1019 if (fmt->flushes == NULL) { | |
1020 return NGX_CONF_ERROR; | |
1021 } | |
1022 | |
573 | 1023 fmt->ops = ngx_array_create(cf->pool, 16, sizeof(ngx_http_log_op_t)); |
501 | 1024 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
|
1025 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
|
1026 } |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1027 |
2261 | 1028 return ngx_http_log_compile_format(cf, fmt->flushes, fmt->ops, cf->args, 2); |
573 | 1029 } |
1030 | |
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 |
573 | 1032 static char * |
2261 | 1033 ngx_http_log_compile_format(ngx_conf_t *cf, ngx_array_t *flushes, |
1034 ngx_array_t *ops, ngx_array_t *args, ngx_uint_t s) | |
573 | 1035 { |
880 | 1036 u_char *data, *p, ch; |
1037 size_t i, len; | |
1038 ngx_str_t *value, var; | |
2261 | 1039 ngx_int_t *flush; |
880 | 1040 ngx_uint_t bracket; |
1041 ngx_http_log_op_t *op; | |
1042 ngx_http_log_var_t *v; | |
573 | 1043 |
1044 value = args->elts; | |
1045 | |
1046 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
|
1047 |
880 | 1048 for (i = 0; i < value[s].len; i++) { |
1049 if (value[s].data[i] != '%') { | |
1050 continue; | |
1051 } | |
1052 | |
1053 ch = value[s].data[i + 1]; | |
1054 | |
1055 if ((ch >= 'A' && ch <= 'Z') | |
1056 || (ch >= 'a' && ch <= 'z') | |
1057 || ch == '{') | |
1058 { | |
1059 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
1060 "the parameters in the \"%%name\" form are not supported, " | |
1061 "use the \"$variable\" instead"); | |
1062 | |
1063 return NGX_CONF_ERROR; | |
1064 } | |
1065 } | |
1066 | |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1067 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
|
1068 |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1069 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
|
1070 |
573 | 1071 op = ngx_array_push(ops); |
501 | 1072 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
|
1073 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
|
1074 } |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1075 |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1076 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
|
1077 |
880 | 1078 if (value[s].data[i] == '$') { |
569 | 1079 |
1080 if (++i == value[s].len) { | |
1081 goto invalid; | |
1082 } | |
1083 | |
1084 if (value[s].data[i] == '{') { | |
1085 bracket = 1; | |
1086 | |
1087 if (++i == value[s].len) { | |
1088 goto invalid; | |
1089 } | |
1090 | |
1091 var.data = &value[s].data[i]; | |
1092 | |
1093 } else { | |
1094 bracket = 0; | |
1095 var.data = &value[s].data[i]; | |
1096 } | |
1097 | |
1098 for (var.len = 0; i < value[s].len; i++, var.len++) { | |
1099 ch = value[s].data[i]; | |
1100 | |
1101 if (ch == '}' && bracket) { | |
1102 i++; | |
1103 bracket = 0; | |
1104 break; | |
1105 } | |
1106 | |
1107 if ((ch >= 'A' && ch <= 'Z') | |
1108 || (ch >= 'a' && ch <= 'z') | |
1109 || (ch >= '0' && ch <= '9') | |
1110 || ch == '_') | |
1111 { | |
1112 continue; | |
1113 } | |
1114 | |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1115 break; |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1116 } |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1117 |
569 | 1118 if (bracket) { |
1119 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
1120 "the closing bracket in \"%V\" " | |
1121 "variable is missing", &var); | |
1122 return NGX_CONF_ERROR; | |
1123 } | |
1124 | |
1125 if (var.len == 0) { | |
1126 goto invalid; | |
1127 } | |
1128 | |
577 | 1129 if (ngx_strncmp(var.data, "apache_bytes_sent", 17) == 0) { |
1130 ngx_conf_log_error(NGX_LOG_WARN, cf, 0, | |
1131 "use \"$body_bytes_sent\" instead of " | |
1132 "\"$apache_bytes_sent\""); | |
1133 } | |
1134 | |
573 | 1135 for (v = ngx_http_log_vars; v->name.len; v++) { |
1136 | |
1137 if (v->name.len == var.len | |
1138 && ngx_strncmp(v->name.data, var.data, var.len) == 0) | |
1139 { | |
1140 op->len = v->len; | |
1141 op->getlen = NULL; | |
1142 op->run = v->run; | |
1143 op->data = 0; | |
1144 | |
1145 goto found; | |
1146 } | |
1147 } | |
1148 | |
569 | 1149 if (ngx_http_log_variable_compile(cf, op, &var) != NGX_OK) { |
1150 return NGX_CONF_ERROR; | |
1151 } | |
1152 | |
2261 | 1153 if (flushes) { |
1154 | |
1155 flush = ngx_array_push(flushes); | |
1156 if (flush == NULL) { | |
1157 return NGX_CONF_ERROR; | |
1158 } | |
1159 | |
1160 *flush = op->data; /* variable index */ | |
1161 } | |
1162 | |
573 | 1163 found: |
1164 | |
1165 continue; | |
1166 } | |
1167 | |
1168 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
|
1169 |
880 | 1170 while (i < value[s].len && value[s].data[i] != '$') { |
573 | 1171 i++; |
1172 } | |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1173 |
573 | 1174 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
|
1175 |
573 | 1176 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
|
1177 |
573 | 1178 op->len = len; |
1179 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
|
1180 |
573 | 1181 if (len <= sizeof(uintptr_t)) { |
1182 op->run = ngx_http_log_copy_short; | |
1183 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
|
1184 |
573 | 1185 while (len--) { |
1186 op->data <<= 8; | |
1187 op->data |= data[len]; | |
1188 } | |
1189 | |
1190 } else { | |
1191 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
|
1192 |
2049 | 1193 p = ngx_pnalloc(cf->pool, len); |
573 | 1194 if (p == NULL) { |
1195 return NGX_CONF_ERROR; | |
1196 } | |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1197 |
573 | 1198 ngx_memcpy(p, data, len); |
1199 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
|
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 } |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1202 } |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1203 } |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1204 |
569 | 1205 return NGX_CONF_OK; |
1206 | |
1207 invalid: | |
1208 | |
1209 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "invalid parameter \"%s\"", data); | |
1210 | |
1211 return NGX_CONF_ERROR; | |
1212 } | |
1213 | |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
1214 |
2072 | 1215 static char * |
1216 ngx_http_log_open_file_cache(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) | |
1217 { | |
1218 ngx_http_log_loc_conf_t *llcf = conf; | |
1219 | |
1220 time_t inactive, valid; | |
1221 ngx_str_t *value, s; | |
1222 ngx_int_t max, min_uses; | |
1223 ngx_uint_t i; | |
1224 | |
1225 if (llcf->open_file_cache != NGX_CONF_UNSET_PTR) { | |
1226 return "is duplicate"; | |
1227 } | |
1228 | |
1229 value = cf->args->elts; | |
1230 | |
1231 max = 0; | |
1232 inactive = 10; | |
1233 valid = 60; | |
1234 min_uses = 1; | |
1235 | |
1236 for (i = 1; i < cf->args->nelts; i++) { | |
1237 | |
1238 if (ngx_strncmp(value[i].data, "max=", 4) == 0) { | |
1239 | |
1240 max = ngx_atoi(value[i].data + 4, value[i].len - 4); | |
1241 if (max == NGX_ERROR) { | |
1242 goto failed; | |
1243 } | |
1244 | |
1245 continue; | |
1246 } | |
1247 | |
1248 if (ngx_strncmp(value[i].data, "inactive=", 9) == 0) { | |
1249 | |
1250 s.len = value[i].len - 9; | |
1251 s.data = value[i].data + 9; | |
1252 | |
1253 inactive = ngx_parse_time(&s, 1); | |
1254 if (inactive < 0) { | |
1255 goto failed; | |
1256 } | |
1257 | |
1258 continue; | |
1259 } | |
1260 | |
1261 if (ngx_strncmp(value[i].data, "min_uses=", 9) == 0) { | |
1262 | |
1263 min_uses = ngx_atoi(value[i].data + 9, value[i].len - 9); | |
1264 if (min_uses == NGX_ERROR) { | |
1265 goto failed; | |
1266 } | |
1267 | |
1268 continue; | |
1269 } | |
1270 | |
1271 if (ngx_strncmp(value[i].data, "valid=", 6) == 0) { | |
1272 | |
1273 s.len = value[i].len - 6; | |
1274 s.data = value[i].data + 6; | |
1275 | |
1276 valid = ngx_parse_time(&s, 1); | |
1277 if (valid < 0) { | |
1278 goto failed; | |
1279 } | |
1280 | |
1281 continue; | |
1282 } | |
1283 | |
1284 if (ngx_strcmp(value[i].data, "off") == 0) { | |
1285 | |
1286 llcf->open_file_cache = NULL; | |
1287 | |
1288 continue; | |
1289 } | |
1290 | |
1291 failed: | |
1292 | |
1293 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
1294 "invalid \"open_log_file_cache\" parameter \"%V\"", | |
1295 &value[i]); | |
1296 return NGX_CONF_ERROR; | |
1297 } | |
1298 | |
1299 if (llcf->open_file_cache == NULL) { | |
1300 return NGX_CONF_OK; | |
1301 } | |
1302 | |
1303 if (max == 0) { | |
1304 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
1305 "\"open_log_file_cache\" must have \"max\" parameter"); | |
1306 return NGX_CONF_ERROR; | |
1307 } | |
1308 | |
1309 llcf->open_file_cache = ngx_open_file_cache_init(cf->pool, max, inactive); | |
1310 | |
1311 if (llcf->open_file_cache) { | |
1312 | |
1313 llcf->open_file_cache_valid = valid; | |
1314 llcf->open_file_cache_min_uses = min_uses; | |
1315 | |
1316 return NGX_CONF_OK; | |
1317 } | |
1318 | |
1319 return NGX_CONF_ERROR; | |
1320 } | |
1321 | |
1322 | |
569 | 1323 static ngx_int_t |
573 | 1324 ngx_http_log_init(ngx_conf_t *cf) |
569 | 1325 { |
573 | 1326 ngx_str_t *value; |
1327 ngx_array_t a; | |
581 | 1328 ngx_http_handler_pt *h; |
573 | 1329 ngx_http_log_fmt_t *fmt; |
1330 ngx_http_log_main_conf_t *lmcf; | |
569 | 1331 ngx_http_core_main_conf_t *cmcf; |
1332 | |
573 | 1333 lmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_log_module); |
1334 | |
1335 if (lmcf->combined_used) { | |
1336 if (ngx_array_init(&a, cf->pool, 1, sizeof(ngx_str_t)) != NGX_OK) { | |
1337 return NGX_ERROR; | |
1338 } | |
1339 | |
1340 value = ngx_array_push(&a); | |
1341 if (value == NULL) { | |
1342 return NGX_ERROR; | |
1343 } | |
1344 | |
1345 *value = ngx_http_combined_fmt; | |
1346 fmt = lmcf->formats.elts; | |
1347 | |
2261 | 1348 if (ngx_http_log_compile_format(cf, NULL, fmt->ops, &a, 0) |
573 | 1349 != NGX_CONF_OK) |
1350 { | |
1351 return NGX_ERROR; | |
1352 } | |
1353 } | |
1354 | |
1355 cmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_core_module); | |
569 | 1356 |
581 | 1357 h = ngx_array_push(&cmcf->phases[NGX_HTTP_LOG_PHASE].handlers); |
1358 if (h == NULL) { | |
1359 return NGX_ERROR; | |
1360 } | |
1361 | |
1362 *h = ngx_http_log_handler; | |
569 | 1363 |
1364 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
|
1365 } |