mod_debug_sql: Small plugin that enables raw SQL query logging (for debugging)

This commit is contained in:
Kim Alvefur 2016-02-21 19:29:31 +01:00
parent b3b5222557
commit c82c00424d

25
plugins/mod_debug_sql.lua Normal file
View file

@ -0,0 +1,25 @@
-- Enables SQL query logging
--
-- luacheck: ignore 213/uri
local engines = module:shared("/*/sql/connections");
for uri, engine in pairs(engines) do
engine:debug(true);
end
setmetatable(engines, {
__newindex = function (t, uri, engine)
engine:debug(true);
rawset(t, uri, engine);
end
});
function module.unload()
setmetatable(engines, nil);
for uri, engine in pairs(engines) do
engine:debug(false);
end
end