diff options
author | Zhidao HONG <z.hong@f5.com> | 2024-10-14 15:10:06 +0800 |
---|---|---|
committer | Zhidao HONG <z.hong@f5.com> | 2024-10-22 13:40:50 +0800 |
commit | de430edae585d40dacec20dcf4324d7c0ee8fba1 (patch) | |
tree | f8f87e2a5c456b9608c81cadf61dd04cf72e2e6e /src/nxt_tstr.c | |
parent | f6036bbc7c798133e95d107ef99f289281366b0d (diff) | |
download | unit-de430edae585d40dacec20dcf4324d7c0ee8fba1.tar.gz unit-de430edae585d40dacec20dcf4324d7c0ee8fba1.tar.bz2 |
Add flag for newline control in access log entries
This commit introduces a new flag to control the addition of newline
characters in access log entries. This is prepared for fixing the issue
where log entries lack newlines when using JS configuration.
Diffstat (limited to 'src/nxt_tstr.c')
-rw-r--r-- | src/nxt_tstr.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/nxt_tstr.c b/src/nxt_tstr.c index 50df4c47..36d77e69 100644 --- a/src/nxt_tstr.c +++ b/src/nxt_tstr.c @@ -80,16 +80,17 @@ nxt_tstr_compile(nxt_tstr_state_t *state, const nxt_str_t *str, { u_char *p; nxt_tstr_t *tstr; - nxt_bool_t strz; + nxt_bool_t strz, newline; strz = (flags & NXT_TSTR_STRZ) != 0; + newline = (flags & NXT_TSTR_NEWLINE) != 0; tstr = nxt_mp_get(state->pool, sizeof(nxt_tstr_t)); if (nxt_slow_path(tstr == NULL)) { return NULL; } - tstr->str.length = str->length + strz; + tstr->str.length = str->length + newline + strz; tstr->str.start = nxt_mp_nget(state->pool, tstr->str.length); if (nxt_slow_path(tstr->str.start == NULL)) { @@ -98,6 +99,10 @@ nxt_tstr_compile(nxt_tstr_state_t *state, const nxt_str_t *str, p = nxt_cpymem(tstr->str.start, str->start, str->length); + if (newline) { + *p++ = '\n'; + } + if (strz) { *p = '\0'; } @@ -114,7 +119,7 @@ nxt_tstr_compile(nxt_tstr_state_t *state, const nxt_str_t *str, nxt_tstr_str(tstr, &tpl); - tstr->u.js = nxt_js_add_tpl(state->jcf, &tpl, strz); + tstr->u.js = nxt_js_add_tpl(state->jcf, &tpl, flags); if (nxt_slow_path(tstr->u.js == NULL)) { return NULL; } |