1
0
mirror of https://github.com/lxsang/antd-web-apps synced 2024-12-28 10:18:22 +01:00
antd-web-apps/silk/Logger.lua

30 lines
586 B
Lua
Raw Normal View History

2018-08-21 15:22:16 +02:00
Logger = Object:extends{levels = {}}
2018-08-21 15:16:36 +02:00
function Logger:initialize()
end
function Logger:log(msg,level)
2018-08-22 19:38:36 +02:00
if self.levels[level] and ulib.exists(LOG_ROOT) then
local path = LOG_ROOT..DIR_SEP..level..'.txt'
local f = io.open(path, 'a')
local text = '['..level.."]: "..msg
if f then
f:write(text..'\n')
f:close()
end
print(text)
end
2018-08-21 15:16:36 +02:00
end
function Logger:info(msg)
2018-08-22 19:38:36 +02:00
self:log(msg, "INFO")
2018-08-21 15:16:36 +02:00
end
function Logger:debug(msg)
2018-08-22 19:38:36 +02:00
self:log(msg, "DEBUG")
2018-08-21 15:16:36 +02:00
end
function Logger:error(msg)
2018-08-22 19:38:36 +02:00
self:log(msg, "ERROR")
2018-08-21 15:16:36 +02:00
end