Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions apisix/utils/log-util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ local core = require("apisix.core")

local _M = {}

local function get_full_log(ngx)
local function get_full_log(ngx, conf)
local ctx = ngx.ctx.api_ctx
local var = ctx.var
local service_id
Expand All @@ -34,7 +34,7 @@ local function get_full_log(ngx)
service_id = var.host
end

return {
local log = {
request = {
url = url,
uri = var.request_uri,
Expand All @@ -56,6 +56,12 @@ local function get_full_log(ngx)
start_time = ngx.req.start_time() * 1000,
latency = (ngx.now() - ngx.req.start_time()) * 1000
}

if conf.include_req_body then
log.request.body = ngx.req.get_body_data()
end

return log
end

_M.get_full_log = get_full_log
Expand Down