what about this one (we have a lot of debug_statements all over the place
and are just calling print_debug(MSG) whenever we need it)
debug is configured in a config-file on a per-site-basis and stored in
a lua_shared_dict that gets read via get_waf_config()
it's a little overhead, but probably better than to write the same
code everywhere when you have 100+ debug-points, no?
function print_debug(msg)
local debug = get_waf_config("waf_debug")
if not debug then
debug = "off"
end
if debug = "off" then
return
end
if debug == "on" then
ngx.log(ngx.ERR, "[LUWAF.Debug]["..tostring(msg).."]")
end
end
cheers,
mex
2014-12-09 6:46 GMT+01:00 Yichun Zhang (agentzh) <age...@gmail.com>:
> Hello!
>
> On Mon, Dec 8, 2014 at 8:28 PM, Martin Gee wrote:
>> Just curious, if this "debug" setting is available to do the IF statement,
>> so I don't have to roll my own.
>>
>> Might be useful to expose this in the LUA module.
>>
>
> It's on a different level and you will always pay the price of the
> (eager) Lua function argument evaluation and the Lua function call
> itself when you call ngx.log(), no matter what. Nothing can be as
> cheap as your own Lua "if" statement here.
>
> Regards,
> -agentzh.