-
Notifications
You must be signed in to change notification settings - Fork 0
/
Debug.lua
44 lines (39 loc) · 1.14 KB
/
Debug.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
local DC = DugiContest
DC.Debug = 0
local function GetOriginalContext()
UIParentLoadAddOn("Blizzard_DebugTools")
local orig_DevTools_RunDump = DevTools_RunDump
local originalContext
DevTools_RunDump = function(value, context)
originalContext = context
end
DevTools_Dump("")
DevTools_RunDump = orig_DevTools_RunDump
return originalContext
end
local function DGV_Dump(value)
local context = GetOriginalContext()
local buffer = ""
context.Write = function(self, msg)
buffer = buffer.."\n"..msg
end
DevTools_RunDump(value, context)
return buffer
end
function DC:DebugDump(any)
if not DC.Debug == 1 then return nil end
if type(any)=="string" then return any
elseif any==nil or type(any)=="number" then return tostring(any) end
return DGV_Dump(any)
end
function DC:DebugFormat(header, ...)
if not (DC.Debug == 1) then return end
local value = (header and string.format("Debug %s: ", header)) or "Debug: "
value = string.format("|cff11ff11 %s|r", value)
for i = 1, select('#', ...), 2 do
local name = select(i, ...)
local var = DC:DebugDump(select(i+1, ...))
value = string.format("%s %s=%s", value, name, var)
end
print(value)
end