util/logger.lua

changeset 3455
67cdc0366d46
parent 3357
1dd83dd2b832
child 3540
bc139431830b
equal deleted inserted replaced
3454:8cf30367aa4f 3455:67cdc0366d46
5 -- This project is MIT/X11 licensed. Please see the 5 -- This project is MIT/X11 licensed. Please see the
6 -- COPYING file in the source package for more information. 6 -- COPYING file in the source package for more information.
7 -- 7 --
8 8
9 local pcall = pcall; 9 local pcall = pcall;
10
11 local config = require "core.configmanager";
12 local log_sources = config.get("*", "core", "log_sources");
13 10
14 local find = string.find; 11 local find = string.find;
15 local ipairs, pairs, setmetatable = ipairs, pairs, setmetatable; 12 local ipairs, pairs, setmetatable = ipairs, pairs, setmetatable;
16 13
17 module "logger" 14 module "logger"
24 21
25 local make_logger; 22 local make_logger;
26 local outfunction = nil; 23 local outfunction = nil;
27 24
28 function init(name) 25 function init(name)
29 if log_sources then
30 local log_this = false;
31 for _, source in ipairs(log_sources) do
32 if find(name, source) then
33 log_this = true;
34 break;
35 end
36 end
37
38 if not log_this then return function () end end
39 end
40
41 local log_debug = make_logger(name, "debug"); 26 local log_debug = make_logger(name, "debug");
42 local log_info = make_logger(name, "info"); 27 local log_info = make_logger(name, "info");
43 local log_warn = make_logger(name, "warn"); 28 local log_warn = make_logger(name, "warn");
44 local log_error = make_logger(name, "error"); 29 local log_error = make_logger(name, "error");
45 30

mercurial