aboutsummaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2010-11-04 08:37:39 +0000
committerMatthew Wild <mwild1@gmail.com>2010-11-04 08:37:39 +0000
commitbda78794836dedfb0702f2b5c427937c74ff404f (patch)
tree75d1c363cb459884aa24f527e30ffec996ac5efa /util
parent5f992383c5d661069201d337b5fd3ca4aced6351 (diff)
downloadprosody-bda78794836dedfb0702f2b5c427937c74ff404f.tar.gz
prosody-bda78794836dedfb0702f2b5c427937c74ff404f.zip
util.logger: Remove my precious premature optimisation :(
Diffstat (limited to 'util')
-rw-r--r--util/logger.lua25
1 files changed, 2 insertions, 23 deletions
diff --git a/util/logger.lua b/util/logger.lua
index 1fbd4977..e7095122 100644
--- a/util/logger.lua
+++ b/util/logger.lua
@@ -16,9 +16,6 @@ module "logger"
local name_sinks, level_sinks = {}, {};
local name_patterns = {};
--- Weak-keyed so that loggers are collected
-local modify_hooks = setmetatable({}, { __mode = "k" });
-
local make_logger;
local outfunction = nil;
@@ -54,26 +51,20 @@ function make_logger(source_name, level)
local source_handlers = name_sinks[source_name];
- -- All your premature optimisation is belong to me!
- local num_level_handlers, num_source_handlers = #level_handlers, source_handlers and #source_handlers;
-
local logger = function (message, ...)
if source_handlers then
- for i = 1,num_source_handlers do
+ for i = 1,#source_handlers do
if source_handlers[i](source_name, level, message, ...) == false then
return;
end
end
end
- for i = 1,num_level_handlers do
+ for i = 1,#level_handlers do
level_handlers[i](source_name, level, message, ...);
end
end
- -- To make sure our cached lengths stay in sync with reality
- modify_hooks[logger] = function () num_level_handlers, num_source_handlers = #level_handlers, source_handlers and #source_handlers; end;
-
return logger;
end
@@ -97,10 +88,6 @@ function reset()
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)
@@ -109,10 +96,6 @@ function add_level_sink(level, sink_function)
else
level_sinks[level][#level_sinks[level] + 1 ] = sink_function;
end
-
- for _, modify_hook in pairs(modify_hooks) do
- modify_hook();
- end
end
function add_name_sink(name, sink_function, exclusive)
@@ -121,10 +104,6 @@ function add_name_sink(name, sink_function, exclusive)
else
name_sinks[name][#name_sinks[name] + 1] = sink_function;
end
-
- for _, modify_hook in pairs(modify_hooks) do
- modify_hook();
- end
end
function add_name_pattern_sink(name_pattern, sink_function, exclusive)