Repository navigation
Expand file tree
/
Copy pathDebug.lua
More file actions
122 lines (100 loc) · 2.8 KB
/
Copy pathDebug.lua
File metadata and controls
122 lines (100 loc) · 2.8 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
local addonName, addon = ...
addon = LibStub("AceAddon-3.0"):GetAddon(addonName)
--local Debug = {}
--addon.Debug = Debug
local TextDump = LibStub("LibTextDump-1.0")
--function addon:Debug(text, level)
--if not self.Options or not self.Options.DebugMode then return end
--if (level or 1) <= DBM.Options.DebugLevel then
--local frame = _G[tostring(DBM.Options.ChatFrame)]
--frame = frame and frame:IsShown() and frame or DEFAULT_CHAT_FRAME
--frame:AddMessage("|cffff7d0aDBM Debug:|r "..text, 1, 1, 1)
--fireEvent("DBM_Debug", text, level)
--end
--end
--function SetDebug(value)
--debugPriority = value
--end
debugPriority = 0
-- ----------------------------------------------------------------------------
-- Debugger.
-- ----------------------------------------------------------------------------
local DebugPour, GetDebugger
do
--local TextDump = LibStub("LibTextDump-1.0")
local DEBUGGER_WIDTH = 750
local DEBUGGER_HEIGHT = 800
local debugger
---------
local function Debug(...)
---------
if not debugger then
debugger = TextDump:New(("%s Output"):format(addonName), DEBUGGER_WIDTH, DEBUGGER_HEIGHT)
end
local t = type(...)
if t == "string" then
local message = string.format(...)
debugger:AddLine(message, "%X")
elseif t == "number" then
local message = string.format tostring((...))
debugger:AddLine(message, "%X")
elseif t == "boolean" then
local message = string.format tostring((...))
debugger:AddLine(message, "%X")
elseif t == "table" then
--debugger:AddLine(message, "%X")
--pour(textOrAddon, ...)
else
--error("Invalid argument 2 to :Pour, must be either a string or a table.")
end
return message
end
---------
function DebugPour(...)
---------
DEFAULT_CHAT_FRAME:AddMessage(string.format(...));
Debug(...)
end
---------
function GetDebugger()
---------
if debugPriority <=0 then return end
if not debugger then
debugger = TextDump:New(("%s Output"):format(addonName), DEBUGGER_WIDTH, DEBUGGER_HEIGHT)
end
if debugger:Lines() == 0 then
debugger:AddLine("Nothing to report.")
debugger:Display()
debugger:Clear()
return
end
debugger:Display()
--debugger:Clear()
return debugger
end
---------
function ClearDebugger()
---------
if not debugger then
debugger = TextDump:New(("%s Output"):format(addonName), DEBUGGER_WIDTH, DEBUGGER_HEIGHT)
end
debugger:Clear()
end
--------
function Export(...)
---------
if not debugger then
debugger = TextDump:New(("%s Export"):format(addonName), DEBUGGER_WIDTH, DEBUGGER_HEIGHT)
end
debugger:Clear()
local message = string.format(...)
debugger:AddLine(message)
debugger:Display()
return debugger
end
function addon:Debug(message, prioirity)
if not prioirity or prioirity > debugPriority then return end
GetDebugger()
Debug(message)
end
end