aboutsummaryrefslogtreecommitdiffstats
path: root/util/logger.lua
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2022-03-17 10:19:35 +0000
committerMatthew Wild <mwild1@gmail.com>2022-03-17 10:19:35 +0000
commit9f34801aba7249016e5471ecdeb1b4823ad9d38e (patch)
tree8834e92c1f1f10fc9455c4251fa20148adba30f9 /util/logger.lua
parentc9e223e4f743ad488e8b1ad134f64496a898d512 (diff)
downloadprosody-9f34801aba7249016e5471ecdeb1b4823ad9d38e.tar.gz
prosody-9f34801aba7249016e5471ecdeb1b4823ad9d38e.zip
util.logger: Support for removing individual log sinks without a full reset
Diffstat (limited to 'util/logger.lua')
-rw-r--r--util/logger.lua15
1 files changed, 15 insertions, 0 deletions
diff --git a/util/logger.lua b/util/logger.lua
index 20a5cef2..a94a1ee1 100644
--- a/util/logger.lua
+++ b/util/logger.lua
@@ -10,6 +10,7 @@
local pairs = pairs;
local ipairs = ipairs;
local require = require;
+local t_remove = table.remove;
local _ENV = nil;
-- luacheck: std none
@@ -80,6 +81,19 @@ local function add_simple_sink(simple_sink_function, levels)
end
end
+local function remove_sink(sink_function)
+ local removed;
+ for level, sinks in pairs(level_sinks) do
+ for i = #sinks, 1, -1 do
+ if sinks[i] == sink_function then
+ t_remove(sinks, i);
+ removed = true;
+ end
+ end
+ end
+ return removed;
+end
+
return {
init = init;
make_logger = make_logger;
@@ -87,4 +101,5 @@ return {
add_level_sink = add_level_sink;
add_simple_sink = add_simple_sink;
new = make_logger;
+ remove_sink = remove_sink;
};