Software /
code /
verse
Diff
init.lua @ 142:ea753bc81a33
verse: Add verse.filter_log(levels, logger) to filter a logger for certain levels
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Wed, 15 Sep 2010 16:52:18 +0100 |
parent | 141:15706f6492ae |
child | 162:2950079d4319 |
line wrap: on
line diff
--- a/init.lua Wed Sep 15 16:51:17 2010 +0100 +++ b/init.lua Wed Sep 15 16:52:18 2010 +0100 @@ -35,6 +35,18 @@ server.setlogger(logger); end +function verse.filter_log(levels, logger) + local level_set = {}; + for _, level in ipairs(levels) do + level_set[level] = true; + end + return function (level, name, ...) + if level_set[level] then + return logger(level, name, ...); + end + end; +end + local function error_handler(err) verse.log("error", "Error: %s", err); verse.log("error", "Traceback: %s", debug.traceback());