Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

log_format #9

Closed
denji opened this issue Oct 15, 2018 · 4 comments
Closed

log_format #9

denji opened this issue Oct 15, 2018 · 4 comments
Labels

Comments

@denji
Copy link

denji commented Oct 15, 2018

Multiline log_format does not correction the alignment

Input data:

http {
    log_format  main  '.......'
                     '....';
}

Output result

http {
    log_format  main  '.......'
    '....';
}
@RickieL
Copy link
Contributor

RickieL commented Oct 17, 2018

I think the output result is the better format.

@gethiox
Copy link

gethiox commented May 8, 2019

Another related issue is that formatter is actually breaking multiline string values with braces. (eg. json)
failing test:

def test_multiline_string(self):
    self._check_formatting(
        (
            """http {\n"""
            """    log_format le_json '{"time":"$time_iso8601", '\n"""
            """    '"client_agent":"$client_agent",\n"""
            """    '"user_agent":"$http_user_agent"}';\n"""
            """}\n"""
        ),
        (
            """http {\n"""
            """    log_format le_json '{"time":"$time_iso8601", '\n"""
            """    '"client_agent":"$client_agent",\n"""
            """    '"user_agent":"$http_user_agent"}';\n"""
            """}\n"""
        ),
    )

Modified test output:

----------------------------- Captured stdout call -----------------------------
original:
http {
    log_format le_json '{"time":"$time_iso8601", '
    '"client_agent":"$client_agent",
    '"user_agent":"$http_user_agent"}';
}

formatted:
http {
    log_format le_json ' {
        "time":"$time_iso8601", '
        '"client_agent":"$client_agent",
        '"user_agent":"$http_user_agent"
    }
    ';
}

And this causes three unnecessary newlines on output for each log record.

@denji
Copy link
Author

denji commented May 8, 2019

Could we use the official nginxinc/crossplane parser to improve code quality?

@slomkowski
Copy link
Owner

@denji my goal was to be without any dependencies (just Python), so deployment to various environments is easy (just copy the script). So I won't accept introducing 3rd party libs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants