From 71d2dced8dd98ce1b1bf67e2ebbae981cf85287c Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sun, 21 Feb 2016 19:29:31 +0100 Subject: mod_debug_sql: Small plugin that enables raw SQL query logging (for debugging) --- plugins/mod_debug_sql.lua | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 plugins/mod_debug_sql.lua (limited to 'plugins/mod_debug_sql.lua') diff --git a/plugins/mod_debug_sql.lua b/plugins/mod_debug_sql.lua new file mode 100644 index 00000000..7bbbbd88 --- /dev/null +++ b/plugins/mod_debug_sql.lua @@ -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 + + -- cgit v1.2.3