Annotate

plugins/mod_debug_sql.lua @ 7189:72839cafdf36

util.crand: Include stdlib.h instead of malloc.h for portability (thanks Tobias)
author Kim Alvefur <zash@zash.se>
date Mon, 22 Feb 2016 22:56:05 +0100
parent 7176:b8bbd5f91ad9
child 8391:5edb0d01a94f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7176
b8bbd5f91ad9 mod_debug_sql: Small plugin that enables raw SQL query logging (for debugging)
Kim Alvefur <zash@zash.se>
parents:
diff changeset
1 -- Enables SQL query logging
b8bbd5f91ad9 mod_debug_sql: Small plugin that enables raw SQL query logging (for debugging)
Kim Alvefur <zash@zash.se>
parents:
diff changeset
2 --
b8bbd5f91ad9 mod_debug_sql: Small plugin that enables raw SQL query logging (for debugging)
Kim Alvefur <zash@zash.se>
parents:
diff changeset
3 -- luacheck: ignore 213/uri
b8bbd5f91ad9 mod_debug_sql: Small plugin that enables raw SQL query logging (for debugging)
Kim Alvefur <zash@zash.se>
parents:
diff changeset
4
b8bbd5f91ad9 mod_debug_sql: Small plugin that enables raw SQL query logging (for debugging)
Kim Alvefur <zash@zash.se>
parents:
diff changeset
5 local engines = module:shared("/*/sql/connections");
b8bbd5f91ad9 mod_debug_sql: Small plugin that enables raw SQL query logging (for debugging)
Kim Alvefur <zash@zash.se>
parents:
diff changeset
6
b8bbd5f91ad9 mod_debug_sql: Small plugin that enables raw SQL query logging (for debugging)
Kim Alvefur <zash@zash.se>
parents:
diff changeset
7 for uri, engine in pairs(engines) do
b8bbd5f91ad9 mod_debug_sql: Small plugin that enables raw SQL query logging (for debugging)
Kim Alvefur <zash@zash.se>
parents:
diff changeset
8 engine:debug(true);
b8bbd5f91ad9 mod_debug_sql: Small plugin that enables raw SQL query logging (for debugging)
Kim Alvefur <zash@zash.se>
parents:
diff changeset
9 end
b8bbd5f91ad9 mod_debug_sql: Small plugin that enables raw SQL query logging (for debugging)
Kim Alvefur <zash@zash.se>
parents:
diff changeset
10
b8bbd5f91ad9 mod_debug_sql: Small plugin that enables raw SQL query logging (for debugging)
Kim Alvefur <zash@zash.se>
parents:
diff changeset
11 setmetatable(engines, {
b8bbd5f91ad9 mod_debug_sql: Small plugin that enables raw SQL query logging (for debugging)
Kim Alvefur <zash@zash.se>
parents:
diff changeset
12 __newindex = function (t, uri, engine)
b8bbd5f91ad9 mod_debug_sql: Small plugin that enables raw SQL query logging (for debugging)
Kim Alvefur <zash@zash.se>
parents:
diff changeset
13 engine:debug(true);
b8bbd5f91ad9 mod_debug_sql: Small plugin that enables raw SQL query logging (for debugging)
Kim Alvefur <zash@zash.se>
parents:
diff changeset
14 rawset(t, uri, engine);
b8bbd5f91ad9 mod_debug_sql: Small plugin that enables raw SQL query logging (for debugging)
Kim Alvefur <zash@zash.se>
parents:
diff changeset
15 end
b8bbd5f91ad9 mod_debug_sql: Small plugin that enables raw SQL query logging (for debugging)
Kim Alvefur <zash@zash.se>
parents:
diff changeset
16 });
b8bbd5f91ad9 mod_debug_sql: Small plugin that enables raw SQL query logging (for debugging)
Kim Alvefur <zash@zash.se>
parents:
diff changeset
17
b8bbd5f91ad9 mod_debug_sql: Small plugin that enables raw SQL query logging (for debugging)
Kim Alvefur <zash@zash.se>
parents:
diff changeset
18 function module.unload()
b8bbd5f91ad9 mod_debug_sql: Small plugin that enables raw SQL query logging (for debugging)
Kim Alvefur <zash@zash.se>
parents:
diff changeset
19 setmetatable(engines, nil);
b8bbd5f91ad9 mod_debug_sql: Small plugin that enables raw SQL query logging (for debugging)
Kim Alvefur <zash@zash.se>
parents:
diff changeset
20 for uri, engine in pairs(engines) do
b8bbd5f91ad9 mod_debug_sql: Small plugin that enables raw SQL query logging (for debugging)
Kim Alvefur <zash@zash.se>
parents:
diff changeset
21 engine:debug(false);
b8bbd5f91ad9 mod_debug_sql: Small plugin that enables raw SQL query logging (for debugging)
Kim Alvefur <zash@zash.se>
parents:
diff changeset
22 end
b8bbd5f91ad9 mod_debug_sql: Small plugin that enables raw SQL query logging (for debugging)
Kim Alvefur <zash@zash.se>
parents:
diff changeset
23 end
b8bbd5f91ad9 mod_debug_sql: Small plugin that enables raw SQL query logging (for debugging)
Kim Alvefur <zash@zash.se>
parents:
diff changeset
24
b8bbd5f91ad9 mod_debug_sql: Small plugin that enables raw SQL query logging (for debugging)
Kim Alvefur <zash@zash.se>
parents:
diff changeset
25