aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2012-03-15 19:09:24 +0000
committerMatthew Wild <mwild1@gmail.com>2012-03-15 19:09:24 +0000
commitfe16dde20be2082bb44788113d416ecb35955ad1 (patch)
tree198f2fd542f60ed9e0df17459ff8300ae7f70a2a
parent8a4a259bde8e94104a5b9ea59290c29d5f835493 (diff)
downloadprosody-fe16dde20be2082bb44788113d416ecb35955ad1.tar.gz
prosody-fe16dde20be2082bb44788113d416ecb35955ad1.zip
loggingmanager, util.logger: Remove name sinks and the ability to filter logs by source name (lots of code, hardly used if at all, and possibly broken)
-rw-r--r--core/loggingmanager.lua34
-rw-r--r--util/logger.lua31
2 files changed, 7 insertions, 58 deletions
diff --git a/core/loggingmanager.lua b/core/loggingmanager.lua
index 426425c1..56a3ee2c 100644
--- a/core/loggingmanager.lua
+++ b/core/loggingmanager.lua
@@ -48,34 +48,12 @@ local logging_levels = { "debug", "info", "warn", "error" }
local function add_rule(sink_config)
local sink_maker = log_sink_types[sink_config.to];
if sink_maker then
- if sink_config.levels and not sink_config.source then
- -- Create sink
- local sink = sink_maker(sink_config);
-
- -- Set sink for all chosen levels
- for level in pairs(get_levels(sink_config.levels)) do
- logger.add_level_sink(level, sink);
- end
- elseif sink_config.source and not sink_config.levels then
- logger.add_name_sink(sink_config.source, sink_maker(sink_config));
- elseif sink_config.source and sink_config.levels then
- local levels = get_levels(sink_config.levels);
- local sink = sink_maker(sink_config);
- logger.add_name_sink(sink_config.source,
- function (name, level, ...)
- if levels[level] then
- return sink(name, level, ...);
- end
- end);
- else
- -- All sources
- -- Create sink
- local sink = sink_maker(sink_config);
-
- -- Set sink for all levels
- for _, level in pairs(logging_levels) do
- logger.add_level_sink(level, sink);
- end
+ -- Create sink
+ local sink = sink_maker(sink_config);
+
+ -- Set sink for all chosen levels
+ for level in pairs(get_levels(sink_config.levels or logging_levels)) do
+ logger.add_level_sink(level, sink);
end
else
-- No such sink type
diff --git a/util/logger.lua b/util/logger.lua
index c3bf3992..4fadb4b9 100644
--- a/util/logger.lua
+++ b/util/logger.lua
@@ -13,8 +13,7 @@ local ipairs, pairs, setmetatable = ipairs, pairs, setmetatable;
module "logger"
-local name_sinks, level_sinks = {}, {};
-local name_patterns = {};
+local level_sinks = {};
local make_logger;
@@ -46,17 +45,7 @@ function make_logger(source_name, level)
level_sinks[level] = level_handlers;
end
- local source_handlers = name_sinks[source_name];
-
local logger = function (message, ...)
- if source_handlers then
- for i = 1,#source_handlers do
- if source_handlers[i](source_name, level, message, ...) == false then
- return;
- end
- end
- end
-
for i = 1,#level_handlers do
level_handlers[i](source_name, level, message, ...);
end
@@ -66,14 +55,12 @@ function make_logger(source_name, level)
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
end
function add_level_sink(level, sink_function)
@@ -84,22 +71,6 @@ function add_level_sink(level, sink_function)
end
end
-function add_name_sink(name, sink_function, exclusive)
- if not name_sinks[name] then
- name_sinks[name] = { sink_function };
- else
- name_sinks[name][#name_sinks[name] + 1] = sink_function;
- end
-end
-
-function add_name_pattern_sink(name_pattern, sink_function, exclusive)
- if not name_patterns[name_pattern] then
- name_patterns[name_pattern] = { sink_function };
- else
- name_patterns[name_pattern][#name_patterns[name_pattern] + 1] = sink_function;
- end
-end
-
_M.new = make_logger;
return _M;