summaryrefslogtreecommitdiffstats
path: root/lualib/lua_util.lua
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2018-12-31 11:31:16 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2018-12-31 11:31:16 +0000
commita72937fcfbd01b7d47bde8a46f73d01812f13ce0 (patch)
tree07044e21500bb1d6d97e5b1a24b38bf16a54da88 /lualib/lua_util.lua
parente9c96fdb286727b1a95b8484e7d4e2877bbc3629 (diff)
downloadrspamd-a72937fcfbd01b7d47bde8a46f73d01812f13ce0.tar.gz
rspamd-a72937fcfbd01b7d47bde8a46f73d01812f13ce0.zip
[Minor] Lua_util: Implement debug aliases
Diffstat (limited to 'lualib/lua_util.lua')
-rw-r--r--lualib/lua_util.lua35
1 files changed, 31 insertions, 4 deletions
diff --git a/lualib/lua_util.lua b/lualib/lua_util.lua
index 0d56e689d..b12a258f5 100644
--- a/lualib/lua_util.lua
+++ b/lualib/lua_util.lua
@@ -770,6 +770,7 @@ end
-- Debugging support
local unconditional_debug = false
local debug_modules = {}
+local debug_aliases = {}
local log_level = 384 -- debug + forced (1 << 7 | 1 << 8)
if type(rspamd_config) == 'userdata' then
@@ -784,10 +785,22 @@ if type(rspamd_config) == 'userdata' then
end
end
- if not unconditional_debug and logging.debug_modules then
- for _,m in ipairs(logging.debug_modules) do
- debug_modules[m] = true
- logger.infox(rspamd_config, 'enable debug for Lua module %s', m)
+ if not unconditional_debug then
+ if logging.debug_modules then
+ for _,m in ipairs(logging.debug_modules) do
+ debug_modules[m] = true
+ logger.infox(rspamd_config, 'enable debug for Lua module %s', m)
+ end
+ end
+
+ if #debug_aliases > 0 then
+ for alias,mod in pairs(debug_aliases) do
+ if debug_modules[mod] then
+ debug_modules[alias] = true
+ logger.infox(rspamd_config, 'enable debug for Lua module %s (%s aliased)',
+ alias, mod)
+ end
+ end
end
end
end
@@ -808,6 +821,20 @@ exports.debugm = function(mod, obj_or_fmt, fmt_or_something, ...)
end
end
+--[[[
+-- @function lua_util.add_debug_alias(mod, alias)
+-- Add debugging alias so logging to `alias` will be treated as logging to `mod`
+--]]
+exports.add_debug_alias = function(mod, alias)
+ local logger = require "rspamd_logger"
+ debug_aliases[alias] = mod
+
+ if debug_modules[mod] then
+ debug_modules[alias] = true
+ logger.infox(rspamd_config, 'enable debug for Lua module %s (%s aliased)',
+ alias, mod)
+ end
+end
---[[[
-- @function lua_util.get_task_verdict(task)
-- Returns verdict for a task, must be called from idempotent filters only