diff options
Diffstat (limited to 'plugins/mod_debug_sql.lua')
-rw-r--r-- | plugins/mod_debug_sql.lua | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/plugins/mod_debug_sql.lua b/plugins/mod_debug_sql.lua new file mode 100644 index 00000000..74cc2f68 --- /dev/null +++ b/plugins/mod_debug_sql.lua @@ -0,0 +1,27 @@ +-- 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 + + |