Software /
code /
prosody-modules
Diff
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 |
line wrap: on
line diff
--- a/mod_log_events/mod_log_events.lua Mon Dec 21 12:24:21 2015 +0100 +++ b/mod_log_events/mod_log_events.lua Tue Dec 22 17:54:25 2015 +0000 @@ -2,12 +2,16 @@ local helpers = require "util.helpers"; -helpers.log_events(prosody.events, "global", module._log); +local function init(module, events, name) + helpers.log_events(events, name, module._log); + + function module.unload() + helpers.revert_log_events(events); + end +end + +init(module, prosody.events, "global"); function module.add_host(module) - helpers.log_events(prosody.hosts[module.host].events, module.host, module._log); + init(module, prosody.hosts[module.host].events, module.host); end - -function module.remove_host(module) - helpers.revert_log_events(prosody.hosts[module.host].events); -end