modulemanager: Update logger when a module becomes global
authorMatthew Wild <mwild1@gmail.com>
Thu, 30 Apr 2009 00:36:46 +0000 (01:36 +0100)
committerMatthew Wild <mwild1@gmail.com>
Thu, 30 Apr 2009 00:36:46 +0000 (01:36 +0100)
core/modulemanager.lua

index a1d3bef3aafc6e695c2f97b396772fc087b30844..cc48c2f6776ed58cfa29bbdc9408d770a99b01de 100644 (file)
@@ -123,6 +123,10 @@ function load(host, module_name, config)
        -- Use modified host, if the module set one
        modulemap[api_instance.host][module_name] = pluginenv;
        
+       if api_instance.host == "*" and host ~= "*" then
+               api_instance:set_global();
+       end
+               
        return true;
 end
 
@@ -260,6 +264,10 @@ end
 
 function api:set_global()
        self.host = "*";
+       -- Update the logger
+       local _log = logger.init("mod_"..self.name);
+       self.log = function (self, ...) return _log(...); end;
+       self._log = _log;
 end
 
 local function _add_handler(module, origin_type, tag, xmlns, handler)