Software /
code /
verse
Changeset
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 |
parents | 141:15706f6492ae |
children | 143:641c0a1bb330 |
files | init.lua |
diffstat | 1 files changed, 12 insertions(+), 0 deletions(-) [+] |
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());