Comparison

init.lua @ 240:e27bf761bea6

verse: set_log_handler(): Allow nil to be passed for log_handler to disable logging (the default).
author Matthew Wild <mwild1@gmail.com>
date Sun, 27 Nov 2011 22:50:21 +0000
parent 239:65a0d3fcbbad
child 241:931bf313c691
comparison
equal deleted inserted replaced
239:65a0d3fcbbad 240:e27bf761bea6
38 verse.log = verse.logger("verse"); 38 verse.log = verse.logger("verse");
39 39
40 function verse.set_log_handler(log_handler, levels) 40 function verse.set_log_handler(log_handler, levels)
41 levels = levels or { "debug", "info", "warn", "error" }; 41 levels = levels or { "debug", "info", "warn", "error" };
42 logger.reset(); 42 logger.reset();
43 for i, level in ipairs(levels) do 43 if log_handler then
44 logger.add_level_sink(level, log_handler); 44 for i, level in ipairs(levels) do
45 logger.add_level_sink(level, log_handler);
46 end
45 end 47 end
46 end 48 end
47 49
48 local function error_handler(err) 50 local function error_handler(err)
49 verse.log("error", "Error: %s", err); 51 verse.log("error", "Error: %s", err);