summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorZhidao HONG <z.hong@f5.com>2024-10-14 15:16:40 +0800
committerZhidao HONG <z.hong@f5.com>2024-10-22 13:40:56 +0800
commit76cc071ab16cf342afb79b5e0976558215785f2f (patch)
tree417e80d075e04cf30fb1c0ff930d9aae42ba9c73
parentde430edae585d40dacec20dcf4324d7c0ee8fba1 (diff)
downloadunit-76cc071ab16cf342afb79b5e0976558215785f2f.tar.gz
unit-76cc071ab16cf342afb79b5e0976558215785f2f.tar.bz2
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
-rw-r--r--src/nxt_router_access_log.c15
1 files changed, 2 insertions, 13 deletions
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;
}