Software /
code /
prosody
Changeset
883:0112ae30f399
Support to filter logging by source via pattern matching from config file.
author | Tobias Markmann <tm@ayena.de> |
---|---|
date | Sat, 07 Mar 2009 20:33:21 +0100 |
parents | 882:e362bafbbb68 |
children | 884:5758c39285ab |
files | util/logger.lua |
diffstat | 1 files changed, 17 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/util/logger.lua Sat Mar 07 19:28:12 2009 +0000 +++ b/util/logger.lua Sat Mar 07 20:33:21 2009 +0100 @@ -13,8 +13,13 @@ 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 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, ...)