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 -> "template", each pre-parsed into aTemplateat config load and rendered per request viaTemplate::render_with_legacy(supports{{namespace.path}}references plus legacy$varinterpolation).
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).
Enums§
- LogFormat
Value - One entry in a parsed
LogFormat: a string value is pre-parsed into aTemplateat config-load time (one parse, per-request render); a number/boolean scalar is kept as-is and rendered verbatim.
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 aLogFormat, orNonewhen absent. Returns an error if it is present but not an object of scalar values. String values are pre-parsed intoTemplates here (warnings discarded — the compile-time walk, a later task, reports them); number/boolean values pass through unchanged. - reads_
response_ body - Whether a logger with this configuration reads
context.response.body. - request_
uri 🔒 - Path plus sorted query string.
Type Aliases§
- LogFormat
- A parsed
log_format: entry name -> pre-parsed value.