Comparison

util/logger.lua @ 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
parent 2923:b7049746bd29
child 3455:67cdc0366d46
comparison
equal deleted inserted replaced
3356:cf6be653c619 3357:1dd83dd2b832
101 ret = old_func; 101 ret = old_func;
102 end 102 end
103 return ok, ret; 103 return ok, ret;
104 end 104 end
105 105
106 function reset()
107 for k in pairs(name_sinks) do name_sinks[k] = nil; end
108 for level, handler_list in pairs(level_sinks) do
109 -- Clear all handlers for this level
110 for i = 1, #handler_list do
111 handler_list[i] = nil;
112 end
113 end
114 for k in pairs(name_patterns) do name_patterns[k] = nil; end
115
116 for _, modify_hook in pairs(modify_hooks) do
117 modify_hook();
118 end
119 end
120
106 function add_level_sink(level, sink_function) 121 function add_level_sink(level, sink_function)
107 if not level_sinks[level] then 122 if not level_sinks[level] then
108 level_sinks[level] = { sink_function }; 123 level_sinks[level] = { sink_function };
109 else 124 else
110 level_sinks[level][#level_sinks[level] + 1 ] = sink_function; 125 level_sinks[level][#level_sinks[level] + 1 ] = sink_function;