Skip to content
This repository was archived by the owner on Oct 8, 2025. It is now read-only.

Conversation

hongzhidao
Copy link
Contributor

@hongzhidao hongzhidao commented Oct 14, 2024

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

@hongzhidao hongzhidao requested review from ac000 and javorszky October 14, 2024 08:23
Copy link
Member

@ac000 ac000 left a 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.
Copy link
Member

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...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to know.

Comment on lines 85 to +86
strz = (flags & NXT_TSTR_STRZ) != 0;
newline = (flags & NXT_TSTR_NEWLINE) != 0;
Copy link
Member

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...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense.

Copy link
Contributor Author

@hongzhidao hongzhidao Oct 22, 2024

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.

Copy link
Member

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...

Copy link
Contributor Author

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.

@ac000
Copy link
Member

ac000 commented Oct 15, 2024

Looks like the tests will need tweaking https://github.com/nginx/unit/actions/runs/11337821193/job/31530024356?pr=1459.

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
Copy link
Member

@ac000 ac000 left a 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).

@hongzhidao hongzhidao merged commit 76cc071 into nginx:master Oct 23, 2024
23 of 24 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants