File

plugins/mod_debug_sql.lua @ 11359:db146bf7b120

mod_c2s: Reflect stream 'from' attribute back if set (fix #1625) Clients should *not* be setting this before TLS anyways.
author Kim Alvefur <zash@zash.se>
date Wed, 03 Feb 2021 21:41:45 +0100
parent 8391:5edb0d01a94f
line wrap: on
line source

-- 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