Mercurial > hg > nginx
comparison 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 |
comparison
equal
deleted
inserted
replaced
5259:0c699e1d1071 | 5260:e088695737c3 |
---|---|
33 | 33 |
34 | 34 |
35 /* STUB NAME */ | 35 /* STUB NAME */ |
36 static ngx_connection_t dumb; | 36 static ngx_connection_t dumb; |
37 /* STUB */ | 37 /* STUB */ |
38 | |
39 static ngx_str_t error_log = ngx_string(NGX_ERROR_LOG_PATH); | |
40 | 38 |
41 | 39 |
42 ngx_cycle_t * | 40 ngx_cycle_t * |
43 ngx_init_cycle(ngx_cycle_t *old_cycle) | 41 ngx_init_cycle(ngx_cycle_t *old_cycle) |
44 { | 42 { |
336 if (ngx_create_paths(cycle, ccf->user) != NGX_OK) { | 334 if (ngx_create_paths(cycle, ccf->user) != NGX_OK) { |
337 goto failed; | 335 goto failed; |
338 } | 336 } |
339 | 337 |
340 | 338 |
341 if (cycle->new_log.file == NULL) { | 339 if (ngx_log_open_default(cycle) != NGX_OK) { |
342 cycle->new_log.file = ngx_conf_open_file(cycle, &error_log); | 340 goto failed; |
343 if (cycle->new_log.file == NULL) { | |
344 goto failed; | |
345 } | |
346 | |
347 cycle->new_log.log_level = NGX_LOG_ERR; | |
348 } | 341 } |
349 | 342 |
350 /* open the new files */ | 343 /* open the new files */ |
351 | 344 |
352 part = &cycle->open_files.part; | 345 part = &cycle->open_files.part; |
581 } | 574 } |
582 | 575 |
583 | 576 |
584 /* commit the new cycle configuration */ | 577 /* commit the new cycle configuration */ |
585 | 578 |
586 if (!ngx_use_stderr && !cycle->log_use_stderr | 579 if (!ngx_use_stderr) { |
587 && cycle->log->file->fd != ngx_stderr) | 580 (void) ngx_log_redirect_stderr(cycle); |
588 { | |
589 if (ngx_set_stderr(cycle->log->file->fd) == NGX_FILE_ERROR) { | |
590 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, | |
591 ngx_set_stderr_n " failed"); | |
592 } | |
593 } | 581 } |
594 | 582 |
595 pool->log = cycle->log; | 583 pool->log = cycle->log; |
596 | 584 |
597 for (i = 0; ngx_modules[i]; i++) { | 585 for (i = 0; ngx_modules[i]; i++) { |
1228 } | 1216 } |
1229 | 1217 |
1230 file[i].fd = fd; | 1218 file[i].fd = fd; |
1231 } | 1219 } |
1232 | 1220 |
1233 if (!cycle->log_use_stderr && cycle->log->file->fd != ngx_stderr) { | 1221 (void) ngx_log_redirect_stderr(cycle); |
1234 | |
1235 if (ngx_set_stderr(cycle->log->file->fd) == NGX_FILE_ERROR) { | |
1236 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, | |
1237 ngx_set_stderr_n " failed"); | |
1238 } | |
1239 } | |
1240 } | 1222 } |
1241 | 1223 |
1242 | 1224 |
1243 ngx_shm_zone_t * | 1225 ngx_shm_zone_t * |
1244 ngx_shared_memory_add(ngx_conf_t *cf, ngx_str_t *name, size_t size, void *tag) | 1226 ngx_shared_memory_add(ngx_conf_t *cf, ngx_str_t *name, size_t size, void *tag) |