Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nginx/nginx.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVladimir Homutov <vl@nginx.com>2013-06-28 17:24:54 +0400
committerVladimir Homutov <vl@nginx.com>2013-06-28 17:24:54 +0400
commitdd3e13eef01e9f04ac447eaa3a1a76575944fc28 (patch)
treeb8652fc39f002250d6032d486e2cde27cf40a0da /src/core/ngx_log.c
parentf41c91511d5435b81f795954d3eb00d38f6acf56 (diff)
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().
Diffstat (limited to 'src/core/ngx_log.c')
-rw-r--r--src/core/ngx_log.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/core/ngx_log.c b/src/core/ngx_log.c
index b35a43218..edf30043d 100644
--- a/src/core/ngx_log.c
+++ b/src/core/ngx_log.c
@@ -363,6 +363,48 @@ ngx_log_init(u_char *prefix)
}
+ngx_int_t
+ngx_log_open_default(ngx_cycle_t *cycle)
+{
+ static ngx_str_t error_log = ngx_string(NGX_ERROR_LOG_PATH);
+
+ if (cycle->new_log.file == NULL) {
+ cycle->new_log.file = ngx_conf_open_file(cycle, &error_log);
+ if (cycle->new_log.file == NULL) {
+ return NGX_ERROR;
+ }
+
+ cycle->new_log.log_level = NGX_LOG_ERR;
+ }
+
+ return NGX_OK;
+}
+
+
+ngx_int_t
+ngx_log_redirect_stderr(ngx_cycle_t *cycle)
+{
+ ngx_fd_t fd;
+
+ if (cycle->log_use_stderr) {
+ return NGX_OK;
+ }
+
+ fd = cycle->log->file->fd;
+
+ if (fd != ngx_stderr) {
+ if (ngx_set_stderr(fd) == NGX_FILE_ERROR) {
+ ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
+ ngx_set_stderr_n " failed");
+
+ return NGX_ERROR;
+ }
+ }
+
+ return NGX_OK;
+}
+
+
static char *
ngx_log_set_levels(ngx_conf_t *cf, ngx_log_t *log)
{