[GH-ISSUE #27] Dumper does not preserve the formatting in log_format #10

Closed
opened 2026-02-28 01:20:29 +03:00 by kerem · 1 comment
Owner

Originally created by @FeiYing9 on GitHub (Oct 19, 2023).
Original GitHub issue: https://github.com/tufanbarisyildirim/gonginx/issues/27

Originally assigned to: @tufanbarisyildirim on GitHub.

I have a log_format like this:

    log_format main '{"@timestamp":"$time_iso8601",'
                    '"host":"$hostname",'
                    '"server_ip":"$server_addr",'
                    '"client_ip":"$remote_addr",'
                    '"remote_user":"$remote_user",'
                    '"xff":"$http_x_forwarded_for",'
                    '"domain":"$host",'
                    '"url":"$uri",'
                    '"referer":"$http_referer",'
                    '"args":"$args",'
                    '"upstream_response_time":"$upstream_response_time",'
                    '"request_time":"$request_time",'
                    '"request_method":"$request_method",'
                    '"status":"$status",'
                    '"size":"$body_bytes_sent",'
                    '"content_length":"$content_length",'
                    '"request_length":"$request_length",'
                    '"protocol":"$server_protocol",'
                    '"upstreamhost":"$upstream_addr",'
                    '"file_dir":"$request_filename",'
                    '"http_user_agent":"$http_user_agent",'
                    '"upstream_cache_status":"$upstream_cache_status",'
                    '"file_name":"$file_name"'
                    '}';

After the dump code ,the result is:

log_format main {@timestamp:, host:, server_ip:, client_ip:, remote_user:, xff:, domain:, url:, referer:, args:, upstream_response_time:, request_time:, request_method:, status:, size:, content_length:, request_length:, protocol:, upstreamhost:, file_dir:, http_user_agent:, upstream_cache_status:, file_name: };
Originally created by @FeiYing9 on GitHub (Oct 19, 2023). Original GitHub issue: https://github.com/tufanbarisyildirim/gonginx/issues/27 Originally assigned to: @tufanbarisyildirim on GitHub. I have a log_format like this: ```nginx log_format main '{"@timestamp":"$time_iso8601",' '"host":"$hostname",' '"server_ip":"$server_addr",' '"client_ip":"$remote_addr",' '"remote_user":"$remote_user",' '"xff":"$http_x_forwarded_for",' '"domain":"$host",' '"url":"$uri",' '"referer":"$http_referer",' '"args":"$args",' '"upstream_response_time":"$upstream_response_time",' '"request_time":"$request_time",' '"request_method":"$request_method",' '"status":"$status",' '"size":"$body_bytes_sent",' '"content_length":"$content_length",' '"request_length":"$request_length",' '"protocol":"$server_protocol",' '"upstreamhost":"$upstream_addr",' '"file_dir":"$request_filename",' '"http_user_agent":"$http_user_agent",' '"upstream_cache_status":"$upstream_cache_status",' '"file_name":"$file_name"' '}'; ``` After the dump code ,the result is: ```nginx log_format main {@timestamp:, host:, server_ip:, client_ip:, remote_user:, xff:, domain:, url:, referer:, args:, upstream_response_time:, request_time:, request_method:, status:, size:, content_length:, request_length:, protocol:, upstreamhost:, file_dir:, http_user_agent:, upstream_cache_status:, file_name: }; ```
kerem 2026-02-28 01:20:29 +03:00
  • closed this issue
  • added the
    v2
    label
Author
Owner

@tufanbarisyildirim commented on GitHub (Feb 20, 2026):

Thanks for reporting this. I re-checked against current main and this appears to be resolved now.

Verification I ran:

  • go test ./parser -run 'TestParser_KeepDataInMultiLine01|TestParser_QuotedString_ISSUE65' (passes)
  • Reproduced your exact log_format sample and ran parse -> dump multiple times; output stayed multiline and stable (it no longer collapses into a single flattened line).

Closing this as fixed in current code.

<!-- gh-comment-id:3932143978 --> @tufanbarisyildirim commented on GitHub (Feb 20, 2026): Thanks for reporting this. I re-checked against current `main` and this appears to be resolved now. Verification I ran: - `go test ./parser -run 'TestParser_KeepDataInMultiLine01|TestParser_QuotedString_ISSUE65'` (passes) - Reproduced your exact `log_format` sample and ran parse -> dump multiple times; output stayed multiline and stable (it no longer collapses into a single flattened line). Closing this as fixed in current code.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/gonginx#10
No description provided.