cave-story-randomizer/caver/log.lua

30 lines
979 B
Lua
Raw Normal View History

2021-04-06 05:58:00 +00:00
local LOG_LEVEL, _logCounts, _logLines = 6, nil, nil
2019-09-10 09:13:50 +00:00
local function _log(level, prefix, text, ...)
if LOG_LEVEL >= level then
local text = prefix .. text
2021-03-29 02:56:33 +00:00
if level ~= 4 then
print(text, ...)
end
2019-09-10 09:13:50 +00:00
table.insert(_logLines, text)
end
_logCounts[level] = _logCounts[level] + 1
end
function logError(...) _log(1, 'ERROR: ', ...) end
function logWarning(...) _log(2, 'WARNING: ', ...) end
function logNotice(...) _log(3, 'NOTICE: ', ...) end
function logSpoiler(...) _log(4, 'SPOILER: ', ...) end
2021-04-06 05:58:00 +00:00
function logSphere(...) _log(5, 'SPHERE: ', ...) end
function logRoute(...) _log(6, 'ROUTE: ', ...) end
function logInfo(...) _log(7, 'INFO: ', ...) end
function logDebug(...) _log(8, 'DEBUG: ', ...) end
2019-09-10 09:13:50 +00:00
function countLogWarningsAndErrors()
return _logCounts[2], _logCounts[1]
end
function getLogText()
return table.concat(_logLines, "\r\n")
end
function resetLog()
2021-04-06 05:58:00 +00:00
_logCounts = {0, 0, 0, 0, 0, 0, 0, 0}
2019-09-10 09:13:50 +00:00
_logLines = {}
end
resetLog()