Comparison

util/logger.lua @ 884:5758c39285ab

util.logger: Small code tidying :)
author Matthew Wild <mwild1@gmail.com>
date Sat, 07 Mar 2009 19:40:00 +0000
parent 883:0112ae30f399
child 896:2c0b9e3c11c3
comparison
equal deleted inserted replaced
883:0112ae30f399 884:5758c39285ab
16 local config = require "core.configmanager"; 16 local config = require "core.configmanager";
17 local log_sources = config.get("*", "core", "log_sources"); 17 local log_sources = config.get("*", "core", "log_sources");
18 18
19 local getstyle, getstring = require "util.termcolours".getstyle, require "util.termcolours".getstring; 19 local getstyle, getstring = require "util.termcolours".getstyle, require "util.termcolours".getstring;
20 local do_pretty_printing = not os.getenv("WINDIR"); 20 local do_pretty_printing = not os.getenv("WINDIR");
21 local find = require "string".find; 21 local find = string.find;
22 local ipairs = ipairs; 22 local ipairs = ipairs;
23 23
24 module "logger" 24 module "logger"
25 25
26 local logstyles = {}; 26 local logstyles = {};
39 function init(name) 39 function init(name)
40 if log_sources then 40 if log_sources then
41 local log_this = false; 41 local log_this = false;
42 for _, source in ipairs(log_sources) do 42 for _, source in ipairs(log_sources) do
43 if find(name, source) then 43 if find(name, source) then
44 log_this = true 44 log_this = true;
45 break 45 break;
46 end 46 end
47 end 47 end
48 48
49 if not log_this then return function () end end 49 if not log_this then return function () end end
50 end 50 end