Diff

plugins/mod_debug_sql.lua @ 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
child 8391:5edb0d01a94f
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
+
+