Mercurial > hg > nginx-quic
comparison src/core/ngx_log.c @ 207:6e0fef527732
nginx-0.0.1-2003-12-05-20:07:27 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Fri, 05 Dec 2003 17:07:27 +0000 |
parents | 267ea1d98683 |
children | 0b67be7d4489 |
comparison
equal
deleted
inserted
replaced
206:9aa426375256 | 207:6e0fef527732 |
---|---|
20 static ngx_str_t errlog_name = ngx_string("errlog"); | 20 static ngx_str_t errlog_name = ngx_string("errlog"); |
21 | 21 |
22 static ngx_command_t ngx_errlog_commands[] = { | 22 static ngx_command_t ngx_errlog_commands[] = { |
23 | 23 |
24 {ngx_string("error_log"), | 24 {ngx_string("error_log"), |
25 NGX_MAIN_CONF|NGX_CONF_TAKE1, | 25 NGX_MAIN_CONF|NGX_CONF_TAKE12, |
26 ngx_set_error_log, | 26 ngx_set_error_log, |
27 0, | 27 0, |
28 0, | 28 0, |
29 NULL}, | 29 NULL}, |
30 | 30 |
231 #if (WIN32) | 231 #if (WIN32) |
232 | 232 |
233 ngx_stderr.fd = GetStdHandle(STD_ERROR_HANDLE); | 233 ngx_stderr.fd = GetStdHandle(STD_ERROR_HANDLE); |
234 | 234 |
235 if (ngx_stderr.fd == NGX_INVALID_FILE) { | 235 if (ngx_stderr.fd == NGX_INVALID_FILE) { |
236 /* TODO: where we can log error ? */ | 236 /* TODO: where can we log error ? */ |
237 return NULL; | 237 return NULL; |
238 | 238 |
239 } else if (ngx_stderr.fd == NULL) { | 239 } else if (ngx_stderr.fd == NULL) { |
240 | |
240 /* there are no associated standard handles */ | 241 /* there are no associated standard handles */ |
241 /* TODO: where we can log possible errors ? */ | 242 |
243 /* TODO: where can we can log possible errors ? */ | |
242 | 244 |
243 ngx_stderr.fd = NGX_INVALID_FILE; | 245 ngx_stderr.fd = NGX_INVALID_FILE; |
244 } | 246 } |
245 | 247 |
246 #else | 248 #else |
249 | 251 |
250 #endif | 252 #endif |
251 | 253 |
252 ngx_log.file = &ngx_stderr; | 254 ngx_log.file = &ngx_stderr; |
253 ngx_log.log_level = NGX_LOG_INFO; | 255 ngx_log.log_level = NGX_LOG_INFO; |
256 | |
257 #if 0 | |
254 /* STUB */ ngx_log.log_level = NGX_LOG_DEBUG; | 258 /* STUB */ ngx_log.log_level = NGX_LOG_DEBUG; |
259 #endif | |
255 | 260 |
256 return &ngx_log; | 261 return &ngx_log; |
257 } | 262 } |
258 | 263 |
259 | 264 |
262 ngx_log_t *log; | 267 ngx_log_t *log; |
263 | 268 |
264 ngx_test_null(log, ngx_pcalloc(cycle->pool, sizeof(ngx_log_t)), NULL); | 269 ngx_test_null(log, ngx_pcalloc(cycle->pool, sizeof(ngx_log_t)), NULL); |
265 ngx_test_null(log->file, ngx_conf_open_file(cycle, name), NULL); | 270 ngx_test_null(log->file, ngx_conf_open_file(cycle, name), NULL); |
266 | 271 |
272 #if 0 | |
267 /* STUB */ log->log_level = NGX_LOG_DEBUG; | 273 /* STUB */ log->log_level = NGX_LOG_DEBUG; |
274 #endif | |
268 | 275 |
269 return log; | 276 return log; |
270 } | 277 } |
271 | 278 |
272 | 279 |
273 static char *ngx_set_error_log(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) | 280 static char *ngx_set_error_log(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) |
274 { | 281 { |
282 ngx_int_t i; | |
275 ngx_str_t *value; | 283 ngx_str_t *value; |
276 | 284 |
277 value = cf->args->elts; | 285 value = cf->args->elts; |
278 | 286 |
279 if (value[1].len == 6 && ngx_strcmp(value[1].data, "stderr") == 0) { | 287 if (value[1].len == 6 && ngx_strcmp(value[1].data, "stderr") == 0) { |
281 | 289 |
282 } else { | 290 } else { |
283 cf->cycle->log->file->name = value[1]; | 291 cf->cycle->log->file->name = value[1]; |
284 } | 292 } |
285 | 293 |
294 if (cf->args->nelts == 3) { | |
295 for (i = 1; i <= /* STUB ??? */ NGX_LOG_DEBUG; i++) { | |
296 if (ngx_strcmp(value[2].data, err_levels[i]) == 0) { | |
297 cf->cycle->log->log_level = i; | |
298 break; | |
299 } | |
300 } | |
301 if (i > NGX_LOG_DEBUG) { | |
302 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
303 "invalid log level \"%s\"", value[2].data); | |
304 return NGX_CONF_ERROR; | |
305 } | |
306 } | |
307 | |
286 return NGX_CONF_OK; | 308 return NGX_CONF_OK; |
287 } | 309 } |
288 | |
289 | |
290 #if 0 | |
291 | |
292 char *ngx_log_set_errlog(ngx_conf_t *cf, ngx_command_t *cmd, ngx_log_t *log) | |
293 { | |
294 int len; | |
295 ngx_err_t err; | |
296 ngx_str_t *value; | |
297 | |
298 value = cf->args->elts; | |
299 | |
300 log->file->fd = ngx_open_file(value[1].data, | |
301 NGX_FILE_RDWR, | |
302 NGX_FILE_CREATE_OR_OPEN|NGX_FILE_APPEND); | |
303 | |
304 if (log->file->fd == NGX_INVALID_FILE) { | |
305 err = ngx_errno; | |
306 len = ngx_snprintf(ngx_conf_errstr, sizeof(ngx_conf_errstr) - 1, | |
307 ngx_open_file_n " \"%s\" failed (%d: ", | |
308 value[1].data, err); | |
309 len += ngx_strerror_r(err, ngx_conf_errstr + len, | |
310 sizeof(ngx_conf_errstr) - len - 1); | |
311 ngx_conf_errstr[len++] = ')'; | |
312 ngx_conf_errstr[len++] = '\0'; | |
313 return ngx_conf_errstr; | |
314 } | |
315 | |
316 #if (WIN32) | |
317 if (ngx_file_append_mode(log->file->fd) == NGX_ERROR) { | |
318 err = ngx_errno; | |
319 len = ngx_snprintf(ngx_conf_errstr, sizeof(ngx_conf_errstr) - 1, | |
320 ngx_file_append_mode_n " \"%s\" failed (%d: ", | |
321 value[1].data, err); | |
322 len += ngx_strerror_r(err, ngx_conf_errstr + len, | |
323 sizeof(ngx_conf_errstr) - len - 1); | |
324 ngx_conf_errstr[len++] = ')'; | |
325 ngx_conf_errstr[len++] = '\0'; | |
326 return ngx_conf_errstr; | |
327 } | |
328 #endif | |
329 | |
330 return NGX_CONF_OK; | |
331 } | |
332 | |
333 #endif |