-- Prosody IM
--- Copyright (C) 2008-2009 Matthew Wild
--- Copyright (C) 2008-2009 Waqas Hussain
+-- Copyright (C) 2008-2010 Matthew Wild
+-- Copyright (C) 2008-2010 Waqas Hussain
--
-- This project is MIT/X11 licensed. Please see the
-- COPYING file in the source package for more information.
local pcall = pcall;
-local config = require "core.configmanager";
-local log_sources = config.get("*", "core", "log_sources");
-
local find = string.find;
local ipairs, pairs, setmetatable = ipairs, pairs, setmetatable;
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
-
local log_debug = make_logger(name, "debug");
local log_info = make_logger(name, "info");
local log_warn = make_logger(name, "warn");
return ok, ret;
end
+function reset()
+ for k in pairs(name_sinks) do name_sinks[k] = nil; end
+ for level, handler_list in pairs(level_sinks) do
+ -- Clear all handlers for this level
+ for i = 1, #handler_list do
+ handler_list[i] = nil;
+ end
+ end
+ for k in pairs(name_patterns) do name_patterns[k] = nil; end
+
+ for _, modify_hook in pairs(modify_hooks) do
+ modify_hook();
+ end
+end
+
function add_level_sink(level, sink_function)
if not level_sinks[level] then
level_sinks[level] = { sink_function };