Update loglevel.lua
Add varargs, print correct level
This commit is contained in:
parent
d796caab04
commit
16b90916b8
21
logging.lua
21
logging.lua
@ -8,6 +8,10 @@ local loglevels={
|
|||||||
["DEBUG"]=5,
|
["DEBUG"]=5,
|
||||||
["TRACE"]=6
|
["TRACE"]=6
|
||||||
}
|
}
|
||||||
|
local loglevels_index={}
|
||||||
|
for k, v in pairs(loglevels) do
|
||||||
|
loglevels_index[v]=k
|
||||||
|
end
|
||||||
|
|
||||||
-- default log level
|
-- default log level
|
||||||
local loglevel="INFO"
|
local loglevel="INFO"
|
||||||
@ -18,17 +22,18 @@ end
|
|||||||
|
|
||||||
logging.setLogLevel("INFO")
|
logging.setLogLevel("INFO")
|
||||||
|
|
||||||
local function printLog(severity, message)
|
local function printLog(severity, ...)
|
||||||
if (loglevels[loglevel]) >= severity then
|
if (loglevels[loglevel]) >= severity then
|
||||||
log("[" .. loglevel .. "] " .. message)
|
log("[" .. loglevels_index[severity] .. "] ", ...)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function logging.fatal(message) printLog(1, message) end
|
function logging.fatal(...) printLog(1, ...) end
|
||||||
function logging.error(message) printLog(2, message) end
|
function logging.error(...) printLog(2, ...) end
|
||||||
function logging.warn(message) printLog(3, message) end
|
function logging.warn(...) printLog(3, ...) end
|
||||||
function logging.info(message) printLog(4, message) end
|
function logging.info(...) printLog(4, ...) end
|
||||||
function logging.debug(message) printLog(5, message) end
|
function logging.debug(...) printLog(5, ...) end
|
||||||
function logging.trace(message) printLog(6, message) end
|
function logging.trace(...) printLog(6, ...) end
|
||||||
|
function logging.test(...) printLog(1, ...) end
|
||||||
|
|
||||||
return logging
|
return logging
|
||||||
|
Loading…
x
Reference in New Issue
Block a user