Comparison

mod_log_events/mod_log_events.lua @ 1995:0e008f36a91c

mod_log_events: No such thing as module.remove_host. Fix this module so it can be loaded/unloaded dynamically and behave (mostly) correctly
author Matthew Wild <mwild1@gmail.com>
date Tue, 22 Dec 2015 17:54:25 +0000
parent 1638:9276473ee5be
comparison
equal deleted inserted replaced
1994:f263fcf1b0ed 1995:0e008f36a91c
1 module:set_global(); 1 module:set_global();
2 2
3 local helpers = require "util.helpers"; 3 local helpers = require "util.helpers";
4 4
5 helpers.log_events(prosody.events, "global", module._log); 5 local function init(module, events, name)
6 helpers.log_events(events, name, module._log);
7
8 function module.unload()
9 helpers.revert_log_events(events);
10 end
11 end
12
13 init(module, prosody.events, "global");
6 14
7 function module.add_host(module) 15 function module.add_host(module)
8 helpers.log_events(prosody.hosts[module.host].events, module.host, module._log); 16 init(module, prosody.hosts[module.host].events, module.host);
9 end 17 end
10
11 function module.remove_host(module)
12 helpers.revert_log_events(prosody.hosts[module.host].events);
13 end