From 0ebce31c9287cb97b626d61b62e83681b2864fe8 Mon Sep 17 00:00:00 2001 From: Alejandro Colomar Date: Thu, 26 Jan 2023 15:07:12 +0100 Subject: HTTP: added route logging. - Configuration: added "/config/settings/http/log_route". Type: bool Default: false This adds configurability to the error log. It allows enabling and disabling logs related to how the router performs selection of the routes. - HTTP: logging request line. Log level: [notice] The request line is essential to understand which logs correspond to which request when reading the logs. - HTTP: logging route that's been discarded. Log level: [info] - HTTP: logging route whose action is selected. Log level: [notice] - HTTP: logging when "fallback" action is taken. Log level: [notice] Closes: Link: Link: Suggested-by: Timo Stark Suggested-by: Mark L Wood-Patrick Suggested-by: Liam Crilly Tested-by: Liam Crilly Acked-by: Artem Konev Cc: Andrew Clayton Cc: Andrei Zeliankou Reviewed-by: Zhidao Hong Signed-off-by: Alejandro Colomar --- src/nxt_h1proto.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/nxt_h1proto.c') diff --git a/src/nxt_h1proto.c b/src/nxt_h1proto.c index 1e37273f..40b10af0 100644 --- a/src/nxt_h1proto.c +++ b/src/nxt_h1proto.c @@ -507,6 +507,7 @@ nxt_h1p_conn_request_init(nxt_task_t *task, void *obj, void *data) r->conf = joint; skcf = joint->socket_conf; + r->log_route = skcf->log_route; if (c->local == NULL) { c->local = skcf->sockaddr; @@ -653,6 +654,11 @@ nxt_h1p_header_process(nxt_task_t *task, nxt_h1proto_t *h1p, r->path = &h1p->parser.path; r->args = &h1p->parser.args; + if (nxt_slow_path(r->log_route)) { + nxt_log(task, NXT_LOG_NOTICE, "http request line \"%V %V %V\"", + r->method, &r->target, &r->version); + } + r->fields = h1p->parser.fields; ret = nxt_http_fields_process(r->fields, &nxt_h1p_fields_hash, r); -- cgit