diff options
author | Matthew Wild <mwild1@gmail.com> | 2010-07-14 01:23:14 +0100 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2010-07-14 01:23:14 +0100 |
commit | 52cde37cdbebf309eca2999f873a236e9e83b942 (patch) | |
tree | cc12f9169d94dbde25c4f86d1a1c7f956cadeb38 /util | |
parent | e5aa3b54328418d0052503bb8d44ab17c5e7b6ad (diff) | |
download | prosody-52cde37cdbebf309eca2999f873a236e9e83b942.tar.gz prosody-52cde37cdbebf309eca2999f873a236e9e83b942.zip |
util.logger: Add reset() method to clear all sinks
Diffstat (limited to 'util')
-rw-r--r-- | util/logger.lua | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/util/logger.lua b/util/logger.lua index fb0bc37b..22b7e41b 100644 --- a/util/logger.lua +++ b/util/logger.lua @@ -103,6 +103,21 @@ function setwriter(f) 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 }; |