diff options
Diffstat (limited to 'src/core')
| -rw-r--r-- | src/core/nginx.c | 10 | ||||
| -rw-r--r-- | src/core/ngx_cycle.c | 2 | ||||
| -rw-r--r-- | src/core/ngx_log.c | 26 | ||||
| -rw-r--r-- | src/core/ngx_log.h | 3 |
4 files changed, 27 insertions, 14 deletions
diff --git a/src/core/nginx.c b/src/core/nginx.c index 0f37f2ad8..a41c55cea 100644 --- a/src/core/nginx.c +++ b/src/core/nginx.c @@ -118,7 +118,7 @@ int main(int argc, char *const *argv) ngx_pid = ngx_getpid(); - if (!(log = ngx_log_init_errlog())) { + if (!(log = ngx_log_init_stderr())) { return 1; } @@ -144,6 +144,14 @@ int main(int argc, char *const *argv) return 1; } + if (ngx_test_config) { + log->log_level = NGX_LOG_INFO; + } else { + if (ngx_log_init_error_log() == NGX_ERROR) { + return 1; + } + } + if (ngx_os_init(log) == NGX_ERROR) { return 1; } diff --git a/src/core/ngx_cycle.c b/src/core/ngx_cycle.c index d0e31c9e0..a545c61d7 100644 --- a/src/core/ngx_cycle.c +++ b/src/core/ngx_cycle.c @@ -223,7 +223,7 @@ ngx_cycle_t *ngx_init_cycle(ngx_cycle_t *old_cycle) NGX_FILE_RDWR, NGX_FILE_CREATE_OR_OPEN|NGX_FILE_APPEND); -#if 1 +#if 0 log->log_level = NGX_LOG_DEBUG_ALL; #endif ngx_log_debug3(NGX_LOG_DEBUG_CORE, log, 0, diff --git a/src/core/ngx_log.c b/src/core/ngx_log.c index fd8f9d940..78f3af5fc 100644 --- a/src/core/ngx_log.c +++ b/src/core/ngx_log.c @@ -224,11 +224,8 @@ void ngx_assert_core(ngx_log_t *log, const char *fmt, ...) #endif - -ngx_log_t *ngx_log_init_errlog() +ngx_log_t *ngx_log_init_stderr() { - ngx_fd_t fd; - #if (WIN32) ngx_stderr.fd = GetStdHandle(STD_ERROR_HANDLE); @@ -253,10 +250,17 @@ ngx_log_t *ngx_log_init_errlog() #endif ngx_log.file = &ngx_stderr; + ngx_log.log_level = NGX_LOG_ERR; -#ifdef NGX_ERROR_LOG_PATH + return &ngx_log; +} - ngx_log.log_level = NGX_LOG_ERR; + +ngx_int_t ngx_log_init_error_log() +{ + ngx_fd_t fd; + +#ifdef NGX_ERROR_LOG_PATH fd = ngx_open_file(NGX_ERROR_LOG_PATH, NGX_FILE_RDWR, NGX_FILE_CREATE_OR_OPEN|NGX_FILE_APPEND); @@ -264,7 +268,7 @@ ngx_log_t *ngx_log_init_errlog() if (fd == NGX_INVALID_FILE) { ngx_log_error(NGX_LOG_EMERG, (&ngx_log), ngx_errno, ngx_open_file_n " \"" NGX_ERROR_LOG_PATH "\" failed"); - return NULL; + return NGX_ERROR; } #if (WIN32) @@ -273,7 +277,7 @@ ngx_log_t *ngx_log_init_errlog() ngx_log_error(NGX_LOG_EMERG, (&ngx_log), ngx_errno, ngx_file_append_mode_n " \"" NGX_ERROR_LOG_PATH "\" failed"); - return NULL; + return NGX_ERROR; } #else @@ -281,18 +285,18 @@ ngx_log_t *ngx_log_init_errlog() if (dup2(fd, STDERR_FILENO) == NGX_ERROR) { ngx_log_error(NGX_LOG_EMERG, (&ngx_log), ngx_errno, "dup2(STDERR) failed"); - return NULL; + return NGX_ERROR; } #endif -#else +#else /* no NGX_ERROR_LOG_PATH */ ngx_log.log_level = NGX_LOG_INFO; #endif - return &ngx_log; + return NGX_OK; } diff --git a/src/core/ngx_log.h b/src/core/ngx_log.h index a3adb0449..4133f9835 100644 --- a/src/core/ngx_log.h +++ b/src/core/ngx_log.h @@ -195,7 +195,8 @@ void ngx_assert_core(ngx_log_t *log, const char *fmt, ...); #define ngx_log_alloc_log(pool, log) ngx_palloc(pool, log, sizeof(ngx_log_t)) #define ngx_log_copy_log(new, old) ngx_memcpy(new, old, sizeof(ngx_log_t)) -ngx_log_t *ngx_log_init_errlog(); +ngx_log_t *ngx_log_init_stderr(); +ngx_int_t ngx_log_init_error_log(); ngx_log_t *ngx_log_create_errlog(ngx_cycle_t *cycle, ngx_array_t *args); char *ngx_set_error_log_levels(ngx_conf_t *cf, ngx_log_t *log); |
