From 8a253c1cc93aa94a1a3782954035720f45e8b96c Mon Sep 17 00:00:00 2001 From: Tobias Markmann Date: Sat, 7 Mar 2009 20:33:21 +0100 Subject: Support to filter logging by source via pattern matching from config file. --- util/logger.lua | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/util/logger.lua b/util/logger.lua index 791e222b..9969f934 100644 --- a/util/logger.lua +++ b/util/logger.lua @@ -13,8 +13,13 @@ local debug = debug; local tostring = tostring; local math_max = math.max; +local config = require "core.configmanager"; +local log_sources = config.get("*", "core", "log_sources"); + local getstyle, getstring = require "util.termcolours".getstyle, require "util.termcolours".getstring; local do_pretty_printing = not os.getenv("WINDIR"); +local find = require "string".find; +local ipairs = ipairs; module "logger" @@ -32,6 +37,18 @@ local sourcewidth = 20; local outfunction = nil; function init(name) + if log_sources then + local log_this = false; + for _, source in ipairs(log_sources) do + if find(name, source) then + log_this = true + break + end + end + + if not log_this then return function () end end + end + --name = nil; -- While this line is not commented, will automatically fill in file/line number info local namelen = #name; return function (level, message, ...) -- cgit v1.2.3