feat: add process_logging

This commit is contained in:
potatso 2023-07-18 13:31:19 +08:00
parent 0ef7a2a9e3
commit 2e848479e8
3 changed files with 15 additions and 1 deletions

View File

@ -69,6 +69,7 @@ location /t {
} }
log_by_lua_block{ log_by_lua_block{
coraza.do_log()
coraza.do_free_transaction() coraza.do_free_transaction()
} }
} }

View File

@ -12,7 +12,7 @@ local err_fmt = log.err_fmt
local warn_fmt = log.warn_fmt local warn_fmt = log.warn_fmt
local _M = { local _M = {
_VERSION = '1.0.0-rc2' _VERSION = '1.0.3'
} }
function _M.create_waf() function _M.create_waf()
@ -118,4 +118,8 @@ function _M.do_body_filter()
response.build_and_process_body(ngx.ctx.transaction) response.build_and_process_body(ngx.ctx.transaction)
end end
function _M.do_log()
coraza.process_logging(ngx.ctx.transaction)
end
return _M return _M

View File

@ -327,4 +327,13 @@ function _M.process_response_body(transaction)
end end
end end
function _M.process_logging(transaction)
local ok, msg = pcall(coraza.coraza_process_logging, transaction)
if ok then
nlog(debug_fmt("success to invoke coraza_process_logging"))
else
nlog(debug_fmt("failed to invoke coraza_process_logging. msg: %s", msg))
end
end
return _M return _M