diff options
author | Tobias Markmann <tm@ayena.de> | 2009-03-07 20:33:21 +0100 |
---|---|---|
committer | Tobias Markmann <tm@ayena.de> | 2009-03-07 20:33:21 +0100 |
commit | 8a253c1cc93aa94a1a3782954035720f45e8b96c (patch) | |
tree | ae5bdd7300bc5cf198ec22ff43ec4de45f45d14a /util | |
parent | 1eeeaf731844a81f039d4b1cab6cdfe20d8d0e30 (diff) | |
download | prosody-8a253c1cc93aa94a1a3782954035720f45e8b96c.tar.gz prosody-8a253c1cc93aa94a1a3782954035720f45e8b96c.zip |
Support to filter logging by source via pattern matching from config file.
Diffstat (limited to 'util')
-rw-r--r-- | util/logger.lua | 17 |
1 files changed, 17 insertions, 0 deletions
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, ...) |