# HG changeset patch # User Matthew Wild # Date 1279066994 -3600 # Node ID 1dd83dd2b832bc7f08294b083fd4b02c6ce4a4ca # Parent cf6be653c619dc08c95ade141e693f4b37bcc9a6 util.logger: Add reset() method to clear all sinks diff -r cf6be653c619 -r 1dd83dd2b832 util/logger.lua --- a/util/logger.lua Tue Jul 13 15:28:52 2010 +0100 +++ b/util/logger.lua Wed Jul 14 01:23:14 2010 +0100 @@ -103,6 +103,21 @@ 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 };