-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
debug.lua
61 lines (55 loc) · 1.67 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
local Addon = select(2, ...)
local Debug = {}
Addon.Debug = Debug
local private = {}
function Debug.Log(msg, ...)
local chatFrame = private.GetDebugChatFrame()
if chatFrame then
Addon:Printf(chatFrame, msg, ...)
end
end
function Debug.TableToString ( t )
local print_r_cache={}
local function sub_print_r(t,indent)
if (print_r_cache[tostring(t)]) then
Addon.Debug.Log(indent.."*"..tostring(t))
else
print_r_cache[tostring(t)]=true
if (type(t)=="table") then
for pos,val in pairs(t) do
if (type(val)=="table") then
Addon.Debug.Log(indent.."["..pos.."] => "..tostring(t).." {")
sub_print_r(val,indent..string.rep(" ",string.len(pos)+8))
Addon.Debug.Log(indent..string.rep(" ",string.len(pos)+6).."}")
elseif (type(val)=="string") then
Addon.Debug.Log(indent.."["..pos..'] => "'..val..'"')
else
Addon.Debug.Log(indent.."["..pos.."] => "..tostring(val))
end
end
else
Addon.Debug.Log(indent..tostring(t))
end
end
end
if (type(t)=="table") then
Addon.Debug.Log(tostring(t).." {")
sub_print_r(t," ")
Addon.Debug.Log("}")
else
sub_print_r(t," ")
end
Addon.Debug.Log("")
end
function private.GetDebugChatFrame() -- private
local tab = -1
for i = 1, 10 do
if GetChatWindowInfo(i)=="BADebug" then
tab = i
break
end
end
if(tab ~= -1) then
return _G["ChatFrame"..tab]
end
end