# HG changeset patch # User Kim Alvefur # Date 1456079371 -3600 # Node ID b8bbd5f91ad90feb3d0e465fb41b36d1fa7a024c # Parent 3e7c6919019321a2a7e03aaf0afddb7d14c4b8fe mod_debug_sql: Small plugin that enables raw SQL query logging (for debugging) diff -r 3e7c69190193 -r b8bbd5f91ad9 plugins/mod_debug_sql.lua --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/plugins/mod_debug_sql.lua Sun Feb 21 19:29:31 2016 +0100 @@ -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 + +