mirror of
https://github.com/nginx/nginx.git
synced 2025-06-28 10:10:39 +08:00
log server address
This commit is contained in:
parent
6d7f8658ed
commit
cc5956772b
@ -47,7 +47,7 @@ typedef u_char *(*ngx_http_log_handler_pt)(ngx_http_request_t *r,
|
|||||||
|
|
||||||
|
|
||||||
struct ngx_http_log_ctx_s {
|
struct ngx_http_log_ctx_s {
|
||||||
ngx_str_t *client;
|
ngx_connection_t *connection;
|
||||||
ngx_http_request_t *request;
|
ngx_http_request_t *request;
|
||||||
ngx_http_request_t *current_request;
|
ngx_http_request_t *current_request;
|
||||||
};
|
};
|
||||||
|
@ -173,7 +173,7 @@ ngx_http_init_connection(ngx_connection_t *c)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx->client = &c->addr_text;
|
ctx->connection = c;
|
||||||
ctx->request = NULL;
|
ctx->request = NULL;
|
||||||
ctx->current_request = NULL;
|
ctx->current_request = NULL;
|
||||||
|
|
||||||
@ -2584,13 +2584,17 @@ ngx_http_log_error(ngx_log_t *log, u_char *buf, size_t len)
|
|||||||
|
|
||||||
ctx = log->data;
|
ctx = log->data;
|
||||||
|
|
||||||
p = ngx_snprintf(buf, len, ", client: %V", ctx->client);
|
p = ngx_snprintf(buf, len, ", client: %V", &ctx->connection->addr_text);
|
||||||
len -= p - buf;
|
len -= p - buf;
|
||||||
|
|
||||||
r = ctx->request;
|
r = ctx->request;
|
||||||
|
|
||||||
if (r) {
|
if (r) {
|
||||||
return r->log_handler(r, ctx->current_request, p, len);
|
return r->log_handler(r, ctx->current_request, p, len);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
p = ngx_snprintf(p, len, ", server: %V",
|
||||||
|
&ctx->connection->listening->addr_text);
|
||||||
}
|
}
|
||||||
|
|
||||||
return p;
|
return p;
|
||||||
|
Loading…
Reference in New Issue
Block a user