-
Notifications
You must be signed in to change notification settings - Fork 363
Fix missing newlines in access logs for JS configuration #1459
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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>
Remember, until GH fixes their parsing we should not enclose Closes:
URLs in <>
.
src/nxt_js.c
Outdated
" return "); | ||
|
||
/* | ||
* Appending a newline character if newline is true. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would rather s/Appending/Append/, because... English... but then this matches the other one...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good to know.
strz = (flags & NXT_TSTR_STRZ) != 0; | ||
newline = (flags & NXT_TSTR_NEWLINE) != 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know why we do the test like this (!= 0) it can only be either set or not.
We don't do it like that in the if () statements...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We missed something here. Because of the calculation below:
tstr->str.length = str->length + newline + strz;
tstr
should be either 0 or 1.
(flags & NXT_TSTR_NEWLINE)
may be greater than 1 but (flags & NXT_TSTR_NEWLINE) != 0
not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, indeed... sorry brain fart on my part...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No worries, tests can help in this case.
d9bbf35
to
8b57ff7
Compare
Looks like the tests will need tweaking https://github.com/nginx/unit/actions/runs/11337821193/job/31530024356?pr=1459. |
8b57ff7
to
dac5540
Compare
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.
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: nginx#1458
dac5540
to
76cc071
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, look good, tests are happy now ;) (apart from wasm-wasi-component which I've noticed has started failing recently, but that's a separate issue).
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.