-
Notifications
You must be signed in to change notification settings - Fork 0
/
LibSimpleLog.lua
63 lines (53 loc) · 1.65 KB
/
LibSimpleLog.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
local SimpleLog = {}
function SimpleLog:new(o)
o = o or {}
setmetatable(o, self)
self.__index = self
-- initialize variables here
o.logLevel = 3
o.logName = ""
return o
end
function SimpleLog:SetLogLevel(logLevel)
self.logLevel = tonumber(logLevel)
end
function SimpleLog:SetLogName(logName)
self.logName = logName
end
function SimpleLog:Debug (message, ...)
if self.logLevel > 3 then
if arg == nil then
Print(string.format("[%s] : %s", self.logName, tostring(message)))
else
Print(string.format("[%s] : %s", self.logName, string.format(message, unpack(arg))))
end
end
end
function SimpleLog:Info (message, ...)
if self.logLevel > 2 then
if arg == nil then
ChatSystemLib.PostOnChannel(2, string.format("[%s] : %s", self.logName, tostring(message)))
else
ChatSystemLib.PostOnChannel(2, string.format("[%s] : %s", self.logName, string.format(message, unpack(arg))))
end
end
end
function SimpleLog:Warn (message, ...)
if self.logLevel > 1 then
if arg == nil then
ChatSystemLib.PostOnChannel(2, string.format("[%s - Warning] : %s", self.logName, tostring(message)))
else
ChatSystemLib.PostOnChannel(2, string.format("[%s - Warning] : %s", self.logName, string.format(message, unpack(arg))))
end
end
end
function SimpleLog:Error (message, ...)
if self.logLevel > 0 then
if arg == nil then
ChatSystemLib.PostOnChannel(2, string.format("[%s - Error] : %s", self.logName, tostring(message)))
else
ChatSystemLib.PostOnChannel(2, string.format("[%s - Error] : %s", self.logName, string.format(message, unpack(arg))))
end
end
end
Apollo.RegisterPackage(SimpleLog, "Blaz:Lib:SimpleLog-0.1", 1, {})