plugins/mod_debug_sql.lua
author Kim Alvefur <zash@zash.se>
Thu, 28 Mar 2024 15:39:59 +0100
changeset 13473 f9171624fd03
parent 8394 5edb0d01a94f
permissions -rw-r--r--
MUC: Fix legacy hats (thanks nicoco) Why do we not have tests for this?

-- Enables SQL query logging
--
-- luacheck: ignore 213/uri

module:set_global();

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