From 4a5bb816e43cb6deddfe58c334257470ff5802be Mon Sep 17 00:00:00 2001 From: uleelx Date: Tue, 7 Apr 2015 19:25:12 +0800 Subject: [PATCH] simplify the logging system implementation --- README.md | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index f04cebd..561eb9f 100644 --- a/README.md +++ b/README.md @@ -93,24 +93,12 @@ local function common_log(logger, level, message) end end -flatdb.hack.debug = function(logger, msg) - common_log(logger, "debug", msg) -end +local levels = {"debug", "info", "warn", "error", "fatal"} -flatdb.hack.info = function(logger, msg) - common_log(logger, "info", msg) -end - -flatdb.hack.warn = function(logger, msg) - common_log(logger, "warn", msg) -end - -flatdb.hack.error = function(logger, msg) - common_log(logger, "error", msg) -end - -flatdb.hack.fatal = function(logger, msg) - common_log(logger, "fatal", msg) +for _, level in ipairs(levels) do + flatdb.hack[level] = function(logger, msg) + common_log(logger, level, msg) + end end flatdb.hack.find = function(logger, level, date)