Software /
code /
prosody
Changeset
7176:b8bbd5f91ad9
mod_debug_sql: Small plugin that enables raw SQL query logging (for debugging)
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sun, 21 Feb 2016 19:29:31 +0100 |
parents | 7175:3e7c69190193 |
children | 7177:1295e14614f4 |
files | plugins/mod_debug_sql.lua |
diffstat | 1 files changed, 25 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /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 + +