Quantcast

Put trace output into its own dialog box.

Johnny C. Lam [07-13-14 - 11:32]
Put trace output into its own dialog box.

This simplifies debugging complex scripts which have enormous traces by
allowing one to copy the trace output and paste it into a text editor for
browsing and searching.

git-svn-id: svn://svn.curseforge.net/wow/ovale/mainline/trunk@1548 d5049fe3-3747-40f7-a4b5-f36d6801af5f
Filename
Ovale.lua
OvaleOptions.lua
conditions/Health.lua
diff --git a/Ovale.lua b/Ovale.lua
index 66369b3..f6aa3a4 100644
--- a/Ovale.lua
+++ b/Ovale.lua
@@ -19,6 +19,7 @@ local format = string.format
 local next = next
 local pairs = pairs
 local select = select
+local tconcat = table.concat
 local tostring = tostring
 local wipe = table.wipe
 local API_GetTime = GetTime
@@ -59,6 +60,7 @@ Ovale.checkBoxes = {}
 Ovale.dropDowns = {}
 -- Flag to activate tracing the function calls for the next frame refresh.
 Ovale.trace = false
+Ovale.traceLog = {}
 --in combat?
 Ovale.enCombat = false
 Ovale.refreshNeeded = {}
@@ -365,13 +367,14 @@ end

 function Ovale:Log(...)
 	if self.trace then
-		self:Print(...)
+		local output = { ... }
+		self.traceLog[#self.traceLog + 1] = tconcat(output, "\t")
 	end
 end

 function Ovale:Logf(...)
 	if self.trace then
-		return self:FormatPrint(...)
+		self.traceLog[#self.traceLog + 1] = self:Format(...)
 	end
 end
 --</public-static-methods>
diff --git a/OvaleOptions.lua b/OvaleOptions.lua
index 742d031..8569727 100644
--- a/OvaleOptions.lua
+++ b/OvaleOptions.lua
@@ -25,8 +25,11 @@ local OvaleState = nil
 local format = string.format
 local strgmatch = string.gmatch
 local strgsub = string.gsub
+local tconcat = table.concat
 local tostring = tostring
+local wipe = table.wipe
 local API_GetSpellInfo = GetSpellInfo
+local API_GetTime = GetTime
 local API_UnitClass = UnitClass

 -- Player's class.
@@ -369,7 +372,7 @@ local self_options =
 				{
 					order = 20,
 					type = "input",
-					multiline = 15,
+					multiline = 25,
 					name = L["Code"],
 					width = "full",
 					disabled = function()
@@ -431,10 +434,71 @@ local self_options =
 			type = "group",
 			args =
 			{
+				toggles =
+				{
+					name = "Options",
+					type = "group",
+					order = 10,
+					args =
+					{
+						-- Node names must match the names of the debug flags.
+						action_bar =
+						{
+							name = "Action bars",
+							desc = L["Debug action bars"],
+							type = "toggle",
+						},
+						aura =
+						{
+							name = "Auras",
+							desc = L["Debug aura"],
+							type = "toggle",
+						},
+						compile =
+						{
+							name = "Compile",
+							desc = L["Debug compile"],
+							type = "toggle",
+						},
+						damage_taken =
+						{
+							name = "Damage taken",
+							desc = L["Debug damage taken"],
+							type = "toggle",
+						},
+						enemy =
+						{
+							name = "Enemies",
+							desc = L["Debug enemies"],
+							type = "toggle",
+						},
+						guid =
+						{
+							name = "GUIDs",
+							desc = L["Debug GUID"],
+							type = "toggle",
+						},
+						paper_doll =
+						{
+							name = "Paper doll updates",
+							desc = L["Debug paper doll"],
+							type = "toggle",
+						},
+						snapshot =
+						{
+							name = "Snapshot updates",
+							desc = L["Debug stat snapshots"],
+							type = "toggle",
+						},
+					},
+					get = function(info) return OvaleOptions.db.profile.debug[info[#info]] end,
+					set = function(info, value) OvaleOptions.db.profile.debug[info[#info]] = value end,
+				},
 				trace =
 				{
 					name = "Trace",
 					type = "group",
+					order = 20,
 					args =
 					{
 						trace =
@@ -442,7 +506,11 @@ local self_options =
 							order = 10,
 							type = "execute",
 							name = "Trace next frame",
-							func = function() Ovale.trace = true end,
+							func = function()
+								wipe(Ovale.traceLog)
+								Ovale.trace = true
+								Ovale:Logf("=== Trace @%f", API_GetTime())
+							end,
 						},
 						traceSpellId =
 						{
@@ -501,64 +569,19 @@ local self_options =
 						},
 					},
 				},
-				toggles =
-				{
-					name = "Options",
+				traceLog = {
+					name = L["Trace Log"],
 					type = "group",
-					args =
-					{
-						-- Node names must match the names of the debug flags.
-						action_bar =
-						{
-							name = "Action bars",
-							desc = L["Debug action bars"],
-							type = "toggle",
-						},
-						aura =
-						{
-							name = "Auras",
-							desc = L["Debug aura"],
-							type = "toggle",
-						},
-						compile =
-						{
-							name = "Compile",
-							desc = L["Debug compile"],
-							type = "toggle",
-						},
-						damage_taken =
-						{
-							name = "Damage taken",
-							desc = L["Debug damage taken"],
-							type = "toggle",
-						},
-						enemy =
-						{
-							name = "Enemies",
-							desc = L["Debug enemies"],
-							type = "toggle",
-						},
-						guid =
-						{
-							name = "GUIDs",
-							desc = L["Debug GUID"],
-							type = "toggle",
-						},
-						paper_doll =
-						{
-							name = "Paper doll updates",
-							desc = L["Debug paper doll"],
-							type = "toggle",
-						},
-						snapshot =
-						{
-							name = "Snapshot updates",
-							desc = L["Debug stat snapshots"],
-							type = "toggle",
+					order = 30,
+					args = {
+						traceLog = {
+							name = L["Trace Log"],
+							type = "input",
+							multiline = 25,
+							width = "full",
+							get = function() return tconcat(Ovale.traceLog, "\n") end,
 						},
 					},
-					get = function(info) return OvaleOptions.db.profile.debug[info[#info]] end,
-					set = function(info, value) OvaleOptions.db.profile.debug[info[#info]] = value end,
 				},
 			},
 		},
@@ -600,13 +623,13 @@ local self_options =
 				{
 					name = "Code",
 					type = "execute",
-					func = function() AceConfigDialog:SetDefaultSize("Ovale", 500, 550); AceConfigDialog:Open("Ovale") end
+					func = function() AceConfigDialog:SetDefaultSize("Ovale", 700, 550); AceConfigDialog:Open("Ovale") end
 				},
 				debug =
 				{
 					name = "Debug",
 					type = "execute",
-					func = function() AceConfigDialog:SetDefaultSize("Ovale", 500, 550); AceConfigDialog:Open("Ovale Debug") end
+					func = function() AceConfigDialog:SetDefaultSize("Ovale Debug", 800, 550); AceConfigDialog:Open("Ovale Debug") end
 				},
 				power =
 				{
diff --git a/conditions/Health.lua b/conditions/Health.lua
index f84fac4..059e550 100644
--- a/conditions/Health.lua
+++ b/conditions/Health.lua
@@ -64,7 +64,6 @@ do
 		if health == 0 then
 			timeToDie = 0
 		elseif maxHealth <= 5 then
-			Ovale:Log("Training Dummy, return in the future")
 			timeToDie = math.huge
 		else
 			local now = floor(currentTime)