2023-01-25 17:01:01 +01:00
|
|
|
Logger = Object:extends{}
|
|
|
|
|
|
|
|
Logger.ERROR = 1
|
|
|
|
Logger.WARN = 2
|
|
|
|
Logger.INFO = 3
|
|
|
|
Logger.DEBUG = 4
|
|
|
|
Logger.handles = {
|
|
|
|
[1] = LOG_ERROR,
|
|
|
|
[2] = LOG_WARN,
|
|
|
|
[3] = LOG_INFO,
|
|
|
|
[4] = LOG_DEBUG
|
|
|
|
}
|
2023-01-18 15:12:48 +01:00
|
|
|
|
|
|
|
function Logger:initialize()
|
2023-01-25 17:01:01 +01:00
|
|
|
if not self.level then
|
|
|
|
self.level = Logger.INFO
|
|
|
|
end
|
2023-01-18 15:12:48 +01:00
|
|
|
end
|
|
|
|
|
2023-01-25 17:01:01 +01:00
|
|
|
function Logger:log(verb,msg,...)
|
|
|
|
local level = verb
|
|
|
|
if level > self.level then return end
|
|
|
|
if level > Logger.DEBUG then
|
|
|
|
level = Logger.DEBUG
|
2023-01-18 15:12:48 +01:00
|
|
|
end
|
2023-01-25 17:01:01 +01:00
|
|
|
Logger.handles[level](msg,...)
|
2023-01-18 15:12:48 +01:00
|
|
|
end
|
|
|
|
|
2023-01-25 17:01:01 +01:00
|
|
|
function Logger:info(msg,...)
|
|
|
|
self:log(Logger.INFO, msg,...)
|
2023-01-18 15:12:48 +01:00
|
|
|
end
|
|
|
|
|
2023-01-25 17:01:01 +01:00
|
|
|
function Logger:debug(msg,...)
|
|
|
|
self:log(Logger.DEBUG, msg,...)
|
2023-01-18 15:12:48 +01:00
|
|
|
end
|
|
|
|
|
2023-01-25 17:01:01 +01:00
|
|
|
function Logger:error(msg,...)
|
|
|
|
self:log(Logger.ERROR, msg,...)
|
|
|
|
end
|
2023-01-18 15:12:48 +01:00
|
|
|
|
2023-01-25 17:01:01 +01:00
|
|
|
function Logger:warn(msg,...)
|
|
|
|
self:log(Logger.WARN, msg,...)
|
2023-01-18 15:12:48 +01:00
|
|
|
end
|