-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLogging.lua
39 lines (32 loc) · 1.01 KB
/
Logging.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
local addonName, addonTable = ...
local SAM = LibStub("AceAddon-3.0"):GetAddon(addonName)
SAM.LogLevel = 0
SAM.LogLevels = {
Always = 0,
Verbose = 1
}
function SAM:Log(msg, logLevel)
if logLevel <= SAM.LogLevel then
local hours, minutes = GetGameTime()
local time = string.format("%02d:%02d", hours, minutes)
print(time.." [|cffff8000SAM|r] "..msg)
end
end
function SAM:LogWarning(msg, logLevel)
if logLevel <= SAM.LogLevel then
local hours, minutes = GetGameTime()
local time = string.format("%02d:%02d", hours, minutes)
print(time.." [|cffff8000SAM|r] |cffe74c3cWarning:|r "..msg)
end
end
function SAM:SetLogLevel(logLevel)
if SAM.LogLevels[logLevel] == nil then
local msg = "No such log level ("..logLevel..") exists. Try one of these:"
for k, v in pairs(SAM.LogLevels) do
msg = msg.."\n"..k
end
SAM:Log(msg, SAM.LogLevels.Always)
return
end
SAM.LogLevel = SAM.LogLevels[logLevel]
end