# HG changeset patch # User Matthew Wild # Date 1552305256 0 # Node ID 78049e8b5a6b97c26b23ec0d9e913707e8827e66 # Parent 0fd7802b435e5b5b2895b0a2fee126a8f0704614 mod_firewall: Improve debug logging for chain results diff -r 0fd7802b435e -r 78049e8b5a6b mod_firewall/actions.lib.lua --- a/mod_firewall/actions.lib.lua Thu Mar 07 23:21:13 2019 +0100 +++ b/mod_firewall/actions.lib.lua Mon Mar 11 11:54:16 2019 +0000 @@ -1,3 +1,6 @@ +local interpolation = require "util.interpolation"; +local template = interpolation.new("%b$$", function (s) return ("%q"):format(s) end); + --luacheck: globals meta idsafe local action_handlers = {}; @@ -193,19 +196,18 @@ end function action_handlers.JUMP_CHAIN(name) - return ([[do - local ret = fire_event(%q, event); - log('debug', 'chain \"%%s\" returned %%s', %q, tostring(ret)); + return template([[do + local ret = fire_event($chain_event$, event); if ret ~= nil then if ret == false then - log("debug", "Chain accepted stanza"); + log("debug", "Chain %q accepted stanza (ret %s)", $chain_name$, tostring(ret)); return pass_return; end - log("debug", "Chain rejected stanza"); + log("debug", "Chain %q rejected stanza (ret %s)", $chain_name$, tostring(ret)); return ret; end - log("debug", "Chain did not accept or reject stanza"); - end]]):format("firewall/chains/"..name, name); + log("debug", "Chain %q did not accept or reject stanza (ret %s)", $chain_name$, tostring(ret)); + end]], { chain_event = "firewall/chains/"..name, chain_name = name }); end function action_handlers.MARK_ORIGIN(name)