Skip to main content

Module log_entry

Module log_entry 

Source
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 no log_format is set.
  • custom entry — a flat object built from a configured log_format map of name -> "$var template", resolved with crate::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_format config value (an object of name -> string) into a map, or None when absent. Returns an error if it is present but not an object of scalar values.
request_uri 🔒
Path plus sorted query string.