Comparison

core/modulemanager.lua @ 1069:034e345c0f8d

modulemanager: Update logger when a module becomes global
author Matthew Wild <mwild1@gmail.com>
date Thu, 30 Apr 2009 01:36:46 +0100
parent 929:b4f2ca7f6f00
child 1094:a619525fed5d
comparison
equal deleted inserted replaced
1067:21f41b06f1d2 1069:034e345c0f8d
121 end 121 end
122 122
123 -- Use modified host, if the module set one 123 -- Use modified host, if the module set one
124 modulemap[api_instance.host][module_name] = pluginenv; 124 modulemap[api_instance.host][module_name] = pluginenv;
125 125
126 if api_instance.host == "*" and host ~= "*" then
127 api_instance:set_global();
128 end
129
126 return true; 130 return true;
127 end 131 end
128 132
129 function get_module(host, name) 133 function get_module(host, name)
130 return modulemap[host] and modulemap[host][name]; 134 return modulemap[host] and modulemap[host][name];
258 return hosts[self.host].type; 262 return hosts[self.host].type;
259 end 263 end
260 264
261 function api:set_global() 265 function api:set_global()
262 self.host = "*"; 266 self.host = "*";
267 -- Update the logger
268 local _log = logger.init("mod_"..self.name);
269 self.log = function (self, ...) return _log(...); end;
270 self._log = _log;
263 end 271 end
264 272
265 local function _add_handler(module, origin_type, tag, xmlns, handler) 273 local function _add_handler(module, origin_type, tag, xmlns, handler)
266 local handlers = stanza_handlers:get(module.host, origin_type, tag, xmlns); 274 local handlers = stanza_handlers:get(module.host, origin_type, tag, xmlns);
267 local msg = (tag == "iq") and "namespace" or "payload namespace"; 275 local msg = (tag == "iq") and "namespace" or "payload namespace";