Mercurial > hg > nginx
diff src/core/ngx_cycle.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 | 3bb51e5afa9e |
children | 3d2d3e1cf427 |
line wrap: on
line diff
--- a/src/core/ngx_cycle.c Tue Jul 02 20:05:49 2013 +0400 +++ b/src/core/ngx_cycle.c Fri Jun 28 17:24:54 2013 +0400 @@ -36,8 +36,6 @@ static ngx_connection_t dumb; /* STUB */ -static ngx_str_t error_log = ngx_string(NGX_ERROR_LOG_PATH); - ngx_cycle_t * ngx_init_cycle(ngx_cycle_t *old_cycle) @@ -338,13 +336,8 @@ } - if (cycle->new_log.file == NULL) { - cycle->new_log.file = ngx_conf_open_file(cycle, &error_log); - if (cycle->new_log.file == NULL) { - goto failed; - } - - cycle->new_log.log_level = NGX_LOG_ERR; + if (ngx_log_open_default(cycle) != NGX_OK) { + goto failed; } /* open the new files */ @@ -583,13 +576,8 @@ /* commit the new cycle configuration */ - if (!ngx_use_stderr && !cycle->log_use_stderr - && cycle->log->file->fd != ngx_stderr) - { - if (ngx_set_stderr(cycle->log->file->fd) == NGX_FILE_ERROR) { - ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, - ngx_set_stderr_n " failed"); - } + if (!ngx_use_stderr) { + (void) ngx_log_redirect_stderr(cycle); } pool->log = cycle->log; @@ -1230,13 +1218,7 @@ file[i].fd = fd; } - if (!cycle->log_use_stderr && cycle->log->file->fd != ngx_stderr) { - - if (ngx_set_stderr(cycle->log->file->fd) == NGX_FILE_ERROR) { - ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, - ngx_set_stderr_n " failed"); - } - } + (void) ngx_log_redirect_stderr(cycle); }