From 76cc071ab16cf342afb79b5e0976558215785f2f Mon Sep 17 00:00:00 2001 From: Zhidao HONG Date: Mon, 14 Oct 2024 15:16:40 +0800 Subject: Fix missing newlines in access logs for JS configuration When using JS configuration for the "format" option, access log entries were being written without newline characters. This commit adds the missing newline character to each log entry. Closes: https://github.com/nginx/unit/issues/1458 --- src/nxt_router_access_log.c | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) (limited to 'src/nxt_router_access_log.c') diff --git a/src/nxt_router_access_log.c b/src/nxt_router_access_log.c index afecd0b1..024bff39 100644 --- a/src/nxt_router_access_log.c +++ b/src/nxt_router_access_log.c @@ -65,7 +65,6 @@ nxt_int_t nxt_router_access_log_create(nxt_task_t *task, nxt_router_conf_t *rtcf, nxt_conf_value_t *value) { - u_char *p; nxt_int_t ret; nxt_str_t str; nxt_tstr_t *format; @@ -121,18 +120,8 @@ nxt_router_access_log_create(nxt_task_t *task, nxt_router_conf_t *rtcf, nxt_memcpy(access_log->path.start, alcf.path.start, alcf.path.length); } - str.length = alcf.format.length + 1; - - str.start = nxt_malloc(str.length); - if (str.start == NULL) { - nxt_alert(task, "failed to allocate log format structure"); - return NXT_ERROR; - } - - p = nxt_cpymem(str.start, alcf.format.start, alcf.format.length); - *p = '\n'; - - format = nxt_tstr_compile(rtcf->tstr_state, &str, NXT_TSTR_LOGGING); + format = nxt_tstr_compile(rtcf->tstr_state, &alcf.format, + NXT_TSTR_LOGGING | NXT_TSTR_NEWLINE); if (nxt_slow_path(format == NULL)) { return NXT_ERROR; } -- cgit