-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDebug.lua
More file actions
62 lines (53 loc) · 1.86 KB
/
Copy pathDebug.lua
File metadata and controls
62 lines (53 loc) · 1.86 KB
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
local addonName, ns = ...
ns.Debug = {}
local Debug = ns.Debug
local PREFIX = "|cff00ccff[Simple Scrolling Loot]|r "
function Debug.Log(fmt, ...)
if ns.Database and ns.Database.Get and ns.Database.Get("debug") then
local msg = select("#", ...) > 0 and string.format(fmt, ...) or tostring(fmt)
if DEFAULT_CHAT_FRAME then
DEFAULT_CHAT_FRAME:AddMessage(PREFIX .. msg)
else
print(PREFIX .. msg)
end
end
end
function Debug.Info(fmt, ...)
local msg = select("#", ...) > 0 and string.format(fmt, ...) or tostring(fmt)
if DEFAULT_CHAT_FRAME then
DEFAULT_CHAT_FRAME:AddMessage(PREFIX .. msg)
else
print(PREFIX .. msg)
end
end
function Debug.Warn(fmt, ...)
local msg = select("#", ...) > 0 and string.format(fmt, ...) or tostring(fmt)
if DEFAULT_CHAT_FRAME then
DEFAULT_CHAT_FRAME:AddMessage(PREFIX .. "|cffffcc00[WARN]|r " .. msg)
else
print(PREFIX .. "[WARN] " .. msg)
end
end
function Debug.Error(fmt, ...)
local msg = select("#", ...) > 0 and string.format(fmt, ...) or tostring(fmt)
if DEFAULT_CHAT_FRAME then
DEFAULT_CHAT_FRAME:AddMessage(PREFIX .. "|cffff3333[ERROR]|r " .. msg)
else
print(PREFIX .. "[ERROR] " .. msg)
end
end
function Debug.LogUnrecognizedLoot(event, rawMessage)
if ns.Database and ns.Database.Get and ns.Database.Get("debug") then
Debug.Log("Unrecognized loot format in %s: '%s'", tostring(event), tostring(rawMessage))
end
end
function Debug.LogEvent(event, ...)
if not ns.Database or not ns.Database.Get or not ns.Database.Get("debug") then
return
end
local values = {}
for index = 1, select("#", ...) do
values[index] = string.format("%d=%s", index, tostring(select(index, ...)))
end
Debug.Log("Event %s args: %s", tostring(event), table.concat(values, ", "))
end