Changeset

3357:1dd83dd2b832

util.logger: Add reset() method to clear all sinks
author Matthew Wild <mwild1@gmail.com>
date Wed, 14 Jul 2010 01:23:14 +0100
parents 3356:cf6be653c619
children 3358:b5a812cf698c
files util/logger.lua
diffstat 1 files changed, 15 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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 };