Expand description
Shared access-log entry builder for the logger plugins.
Every logger (http-logger, tcp-logger, elasticsearch-logger, …) turns the
request Context into the same JSON entry so their output is consistent.
Two shapes, mirroring APISIX’s log-util:
- default entry — a structured object (
request,response,client_ip,latency,consumer, …) when nolog_formatis set. - custom entry — a flat object built from a configured
log_formatmap ofname -> "$var template", resolved withcrate::vars::interpolate.
Latency is derived from the reserved __request_start_ms message key the
data-plane listener stamps at request start; it is omitted when absent
(e.g. in unit tests that build a Context directly).
Functions§
- build_
custom 🔒 - build_
default 🔒 - build_
entry - Builds a log entry for
ctx. - client_
ip 🔒 - Client IP without the port.
- headers_
to_ 🔒json - Header map → JSON object of
name -> [values]. - latency_
ms 🔒 - Milliseconds elapsed since the listener stamped
__request_start_ms. - parse_
log_ format - Parses a
log_formatconfig value (an object ofname -> string) into a map, orNonewhen absent. Returns an error if it is present but not an object of scalar values. - request_
uri 🔒 - Path plus sorted query string.