aboutsummaryrefslogtreecommitdiff
path: root/src/core/ngx_log.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/ngx_log.c')
-rw-r--r--src/core/ngx_log.c19
1 files changed, 8 insertions, 11 deletions
diff --git a/src/core/ngx_log.c b/src/core/ngx_log.c
index 8e9408df0..0c094265e 100644
--- a/src/core/ngx_log.c
+++ b/src/core/ngx_log.c
@@ -315,7 +315,7 @@ ngx_log_errno(u_char *buf, u_char *last, ngx_err_t err)
ngx_log_t *
-ngx_log_init(u_char *prefix)
+ngx_log_init(u_char *prefix, u_char *error_log)
{
u_char *p, *name;
size_t nlen, plen;
@@ -323,13 +323,11 @@ ngx_log_init(u_char *prefix)
ngx_log.file = &ngx_log_file;
ngx_log.log_level = NGX_LOG_NOTICE;
- name = (u_char *) NGX_ERROR_LOG_PATH;
-
- /*
- * we use ngx_strlen() here since BCC warns about
- * condition is always false and unreachable code
- */
+ if (error_log == NULL) {
+ error_log = (u_char *) NGX_ERROR_LOG_PATH;
+ }
+ name = error_log;
nlen = ngx_strlen(name);
if (nlen == 0) {
@@ -369,7 +367,7 @@ ngx_log_init(u_char *prefix)
*p++ = '/';
}
- ngx_cpystrn(p, (u_char *) NGX_ERROR_LOG_PATH, nlen + 1);
+ ngx_cpystrn(p, error_log, nlen + 1);
p = name;
}
@@ -403,8 +401,7 @@ ngx_log_init(u_char *prefix)
ngx_int_t
ngx_log_open_default(ngx_cycle_t *cycle)
{
- ngx_log_t *log;
- static ngx_str_t error_log = ngx_string(NGX_ERROR_LOG_PATH);
+ ngx_log_t *log;
if (ngx_log_get_file_log(&cycle->new_log) != NULL) {
return NGX_OK;
@@ -425,7 +422,7 @@ ngx_log_open_default(ngx_cycle_t *cycle)
log->log_level = NGX_LOG_ERR;
- log->file = ngx_conf_open_file(cycle, &error_log);
+ log->file = ngx_conf_open_file(cycle, &cycle->error_log);
if (log->file == NULL) {
return NGX_ERROR;
}