Mercurial > prosody-modules
comparison mod_http_logging/mod_http_logging.lua @ 2967:135ca695fcbf
mod_http_logging: Use 'ip' field provided by mod_http if available
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Fri, 30 Mar 2018 13:36:38 +0200 |
parents | 678be8ea4d38 |
children | 569b98d6fca1 |
comparison
equal
deleted
inserted
replaced
2966:678be8ea4d38 | 2967:135ca695fcbf |
---|---|
22 end | 22 end |
23 | 23 |
24 local function log_response(response, body) | 24 local function log_response(response, body) |
25 local len = tostring(get_content_len(response, body) or "-"); | 25 local len = tostring(get_content_len(response, body) or "-"); |
26 local request = response.request; | 26 local request = response.request; |
27 local ip = request.conn:ip(); | 27 local ip = request.ip or request.conn:ip(); |
28 local req = string.format("%s %s HTTP/%s", request.method, request.path, request.httpversion); | 28 local req = string.format("%s %s HTTP/%s", request.method, request.path, request.httpversion); |
29 local date = os.date("%d/%m/%Y:%H:%M:%S %z"); | 29 local date = os.date("%d/%m/%Y:%H:%M:%S %z"); |
30 module:log("info", "%s - - [%s] \"%s\" %d %s", ip, date, req, response.status_code, len); | 30 module:log("info", "%s - - [%s] \"%s\" %d %s", ip, date, req, response.status_code, len); |
31 end | 31 end |
32 | 32 |