Introduced the ngx_http_set_connection_log() macro. No functional changes.
diff --git a/src/http/ngx_http_core_module.c b/src/http/ngx_http_core_module.c index 16e6ddb..c491499 100644 --- a/src/http/ngx_http_core_module.c +++ b/src/http/ngx_http_core_module.c
@@ -1461,11 +1461,7 @@ } if (r == r->main) { - r->connection->log->file = clcf->error_log->file; - - if (!(r->connection->log->log_level & NGX_LOG_DEBUG_CONNECTION)) { - r->connection->log->log_level = clcf->error_log->log_level; - } + ngx_http_set_connection_log(r->connection, clcf->error_log); } if ((ngx_io.flags & NGX_IO_SENDFILE) && clcf->sendfile) {
diff --git a/src/http/ngx_http_request.c b/src/http/ngx_http_request.c index c1ee921..9b66718 100644 --- a/src/http/ngx_http_request.c +++ b/src/http/ngx_http_request.c
@@ -443,10 +443,8 @@ #endif clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); - c->log->file = clcf->error_log->file; - if (!(c->log->log_level & NGX_LOG_DEBUG_CONNECTION)) { - c->log->log_level = clcf->error_log->log_level; - } + + ngx_http_set_connection_log(r->connection, clcf->error_log); if (c->buffer == NULL) { c->buffer = ngx_create_temp_buf(c->pool, @@ -1852,11 +1850,8 @@ r->loc_conf = cscf->ctx->loc_conf; clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); - r->connection->log->file = clcf->error_log->file; - if (!(r->connection->log->log_level & NGX_LOG_DEBUG_CONNECTION)) { - r->connection->log->log_level = clcf->error_log->log_level; - } + ngx_http_set_connection_log(r->connection, clcf->error_log); return NGX_OK; }
diff --git a/src/http/ngx_http_request.h b/src/http/ngx_http_request.h index d7d0760..7ceea62 100644 --- a/src/http/ngx_http_request.h +++ b/src/http/ngx_http_request.h
@@ -571,4 +571,12 @@ extern ngx_http_header_out_t ngx_http_headers_out[]; +#define ngx_http_set_connection_log(c, l) \ + \ + c->log->file = l->file; \ + if (!(c->log->log_level & NGX_LOG_DEBUG_CONNECTION)) { \ + c->log->log_level = l->log_level; \ + } + + #endif /* _NGX_HTTP_REQUEST_H_INCLUDED_ */