Mercurial > hg > nginx
comparison src/core/ngx_log.c @ 5260:e088695737c3
Core: consolidated log-related code.
The stderr redirection code is moved to ngx_log_redirect_stderr().
The opening of the default log code is moved to ngx_log_open_default().
author | Vladimir Homutov <vl@nginx.com> |
---|---|
date | Fri, 28 Jun 2013 17:24:54 +0400 |
parents | 7ecaa9e4bf1b |
children | 777202558122 |
comparison
equal
deleted
inserted
replaced
5259:0c699e1d1071 | 5260:e088695737c3 |
---|---|
361 | 361 |
362 return &ngx_log; | 362 return &ngx_log; |
363 } | 363 } |
364 | 364 |
365 | 365 |
366 ngx_int_t | |
367 ngx_log_open_default(ngx_cycle_t *cycle) | |
368 { | |
369 static ngx_str_t error_log = ngx_string(NGX_ERROR_LOG_PATH); | |
370 | |
371 if (cycle->new_log.file == NULL) { | |
372 cycle->new_log.file = ngx_conf_open_file(cycle, &error_log); | |
373 if (cycle->new_log.file == NULL) { | |
374 return NGX_ERROR; | |
375 } | |
376 | |
377 cycle->new_log.log_level = NGX_LOG_ERR; | |
378 } | |
379 | |
380 return NGX_OK; | |
381 } | |
382 | |
383 | |
384 ngx_int_t | |
385 ngx_log_redirect_stderr(ngx_cycle_t *cycle) | |
386 { | |
387 ngx_fd_t fd; | |
388 | |
389 if (cycle->log_use_stderr) { | |
390 return NGX_OK; | |
391 } | |
392 | |
393 fd = cycle->log->file->fd; | |
394 | |
395 if (fd != ngx_stderr) { | |
396 if (ngx_set_stderr(fd) == NGX_FILE_ERROR) { | |
397 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, | |
398 ngx_set_stderr_n " failed"); | |
399 | |
400 return NGX_ERROR; | |
401 } | |
402 } | |
403 | |
404 return NGX_OK; | |
405 } | |
406 | |
407 | |
366 static char * | 408 static char * |
367 ngx_log_set_levels(ngx_conf_t *cf, ngx_log_t *log) | 409 ngx_log_set_levels(ngx_conf_t *cf, ngx_log_t *log) |
368 { | 410 { |
369 ngx_uint_t i, n, d, found; | 411 ngx_uint_t i, n, d, found; |
370 ngx_str_t *value; | 412 ngx_str_t *value; |