Repository navigation
Expand file tree
/
Copy pathLogging.lua
More file actions
323 lines (283 loc) · 13 KB
/
Copy pathLogging.lua
File metadata and controls
323 lines (283 loc) · 13 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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
-- HealIQ Logging.lua
-- Session statistics and diagnostic functionality
-- Use robust global access pattern that works with new Init system
local HealIQ = _G.HealIQ
-- Ensure HealIQ is available (Init.lua should have created it)
if not HealIQ then
error("HealIQ Logging.lua: Init system not loaded - check TOC loading order")
end
-- Create the Logging module
HealIQ.Logging = HealIQ.Logging or {}
local Logging = HealIQ.Logging
-- Initialize logging-related variables on HealIQ object
function Logging:InitializeVariables()
-- Initialize session stats if they don't exist
HealIQ.sessionStats = HealIQ.sessionStats or {
startTime = nil,
suggestions = 0,
rulesProcessed = 0,
errorsLogged = 0,
eventsHandled = 0,
ruleTriggers = {}, -- Track individual rule trigger counts
}
end
-- Initialize session statistics
function HealIQ:InitializeSessionStats()
if self.sessionStats then
self.sessionStats.startTime = time()
end
end
-- Debug logging function - prints to chat in real-time when debug mode is enabled
function HealIQ:DebugLog(message, level)
if not self.debug then
return
end
level = level or "DEBUG"
local timestamp = date("%H:%M:%S")
local logEntry = string.format("[%s] [%s] %s", timestamp, level, tostring(message))
-- Print to chat with color coding
local color = "|cFF888888"
if level == "ERROR" then
color = "|cFFFF0000"
elseif level == "WARN" then
color = "|cFFFFFF00"
elseif level == "INFO" then
color = "|cFF00FF00"
end
print(color .. "[HealIQ] " .. logEntry .. "|r")
end
function HealIQ:LogError(message)
self:DebugLog(message, "ERROR")
if self.sessionStats then
self.sessionStats.errorsLogged = self.sessionStats.errorsLogged + 1
end
end
-- Track rule triggers
function HealIQ:LogRuleTrigger(ruleName)
if self.sessionStats and self.sessionStats.ruleTriggers then
self.sessionStats.ruleTriggers[ruleName] = (self.sessionStats.ruleTriggers[ruleName] or 0) + 1
self.sessionStats.rulesProcessed = (self.sessionStats.rulesProcessed or 0) + 1
end
end
-- Track suggestions made
function HealIQ:LogSuggestionMade()
if self.sessionStats then
self.sessionStats.suggestions = (self.sessionStats.suggestions or 0) + 1
end
end
function HealIQ:GenerateDiagnosticDump()
local dump = {}
-- Header
table.insert(dump, "=== HealIQ Diagnostic Dump ===")
table.insert(dump, "Generated: " .. date("%Y-%m-%d %H:%M:%S"))
table.insert(dump, "Version: " .. self.version)
table.insert(dump, "")
-- Session Statistics with Enhanced Analysis
table.insert(dump, "=== Session Statistics ===")
if self.sessionStats then
local sessionDuration = 0
if self.sessionStats.startTime then
sessionDuration = time() - self.sessionStats.startTime
table.insert(dump, "Session Duration: " .. self:FormatDuration(sessionDuration))
end
table.insert(dump, "Suggestions Generated: " .. (self.sessionStats.suggestions or 0))
table.insert(dump, "Rules Processed: " .. (self.sessionStats.rulesProcessed or 0))
table.insert(dump, "Errors Logged: " .. (self.sessionStats.errorsLogged or 0))
table.insert(dump, "Events Handled: " .. (self.sessionStats.eventsHandled or 0))
-- Performance Analysis
if sessionDuration > 0 and self.sessionStats.suggestions then
local suggestionsPerMinute = (self.sessionStats.suggestions * 60) / sessionDuration
local rulesPerMinute = (self.sessionStats.rulesProcessed * 60) / sessionDuration
table.insert(dump, "")
table.insert(dump, "=== Performance Analysis ===")
table.insert(dump, "Suggestions per Minute: " .. string.format("%.1f", suggestionsPerMinute))
table.insert(dump, "Rules Processed per Minute: " .. string.format("%.1f", rulesPerMinute))
if self.sessionStats.rulesProcessed > 0 then
local efficiency = (self.sessionStats.suggestions / self.sessionStats.rulesProcessed) * 100
table.insert(dump, "Suggestion Efficiency: " .. string.format("%.1f%%", efficiency))
end
end
-- Rule trigger counts with analysis
if self.sessionStats.ruleTriggers and next(self.sessionStats.ruleTriggers) then
table.insert(dump, "")
table.insert(dump, "=== Rule Trigger Analysis ===")
local sortedRules = {}
local totalTriggers = 0
for ruleName, count in pairs(self.sessionStats.ruleTriggers) do
table.insert(sortedRules, {name = ruleName, count = count})
totalTriggers = totalTriggers + count
end
table.sort(sortedRules, function(a, b) return a.count > b.count end)
table.insert(dump, "Most Active Rules:")
for i, rule in ipairs(sortedRules) do
local percentage = (rule.count / totalTriggers) * 100
table.insert(dump, string.format(" %d. %s: %d (%.1f%%)", i, rule.name, rule.count, percentage))
if i >= 5 then break end -- Top 5 only
end
-- Rule frequency recommendations
table.insert(dump, "")
table.insert(dump, "=== Strategy Recommendations ===")
for _, rule in ipairs(sortedRules) do
local percentage = (rule.count / totalTriggers) * 100
if percentage > 50 then
table.insert(dump, "• " .. rule.name .. " is very active (" .. string.format("%.1f%%", percentage) .. ") - consider if this is optimal")
elseif percentage < 5 and rule.count > 0 then
table.insert(dump, "• " .. rule.name .. " rarely triggers (" .. string.format("%.1f%%", percentage) .. ") - consider rule adjustments")
end
end
else
table.insert(dump, "")
table.insert(dump, "Rule Trigger Counts: None yet")
end
else
table.insert(dump, "Session statistics not yet initialized")
end
table.insert(dump, "")
-- Configuration with Strategy Analysis
table.insert(dump, "=== Configuration ===")
if self.db then
table.insert(dump, "Enabled: " .. tostring(self.db.enabled))
table.insert(dump, "Debug Mode: " .. tostring(self.debug))
else
table.insert(dump, "Database not yet initialized")
end
table.insert(dump, "")
-- Enhanced Strategy Configuration Analysis
table.insert(dump, "=== Strategy Configuration Analysis ===")
if self.db and self.db.strategy then
-- Group analysis settings
local groupType = "Unknown"
local groupSize = GetNumGroupMembers()
if groupSize <= 1 then
groupType = "Solo"
elseif groupSize <= 5 then
groupType = "Small Group (5-man)"
elseif groupSize <= 10 then
groupType = "Medium Group (10-man)"
else
groupType = "Large Group (Raid)"
end
table.insert(dump, "Detected Group Type: " .. groupType .. " (" .. groupSize .. " members)")
table.insert(dump, "")
-- Key thresholds with recommendations
table.insert(dump, "Key Thresholds:")
local wildGrowthMin = self.db.strategy.wildGrowthMinTargets or 1
table.insert(dump, " Wild Growth Min Targets: " .. wildGrowthMin)
if groupType == "Solo" and wildGrowthMin > 0 then
table.insert(dump, " → Recommendation: Set to 0 for solo content")
elseif groupType == "Small Group (5-man)" and wildGrowthMin > 2 then
table.insert(dump, " → Recommendation: Consider 1-2 for 5-man content")
elseif groupType == "Large Group (Raid)" and wildGrowthMin < 3 then
table.insert(dump, " → Recommendation: Consider 3+ for raid content")
end
local tranqMin = self.db.strategy.tranquilityMinTargets or 4
table.insert(dump, " Tranquility Min Targets: " .. tranqMin)
if groupType == "Small Group (5-man)" and tranqMin > 3 then
table.insert(dump, " → Recommendation: Consider 2-3 for 5-man content")
end
local effloMin = self.db.strategy.efflorescenceMinTargets or 2
table.insert(dump, " Efflorescence Min Targets: " .. effloMin)
local lowHealthThresh = self.db.strategy.lowHealthThreshold or 0.3
table.insert(dump, " Low Health Threshold: " .. string.format("%.0f%%", lowHealthThresh * 100))
table.insert(dump, "")
table.insert(dump, "Strategy Toggles:")
local strategies = {
{"prioritizeEfflorescence", "Prioritize Efflorescence"},
{"maintainLifebloomOnTank", "Maintain Lifebloom on Tank"},
{"preferClearcastingRegrowth", "Prefer Clearcasting Regrowth"},
{"swiftmendWildGrowthCombo", "Swiftmend + Wild Growth Combo"},
{"useWrathForMana", "Use Wrath for Mana"},
{"emergencyNaturesSwiftness", "Emergency Nature's Swiftness"}
}
for _, strategy in ipairs(strategies) do
local key, name = strategy[1], strategy[2]
local enabled = self.db.strategy[key]
if enabled ~= nil then
table.insert(dump, " " .. name .. ": " .. tostring(enabled))
end
end
else
table.insert(dump, "Strategy configuration not yet initialized")
end
table.insert(dump, "")
-- UI Configuration
table.insert(dump, "=== UI Configuration ===")
if self.db and self.db.ui then
table.insert(dump, "Scale: " .. tostring(self.db.ui.scale))
table.insert(dump, "Position: " .. self.db.ui.x .. ", " .. self.db.ui.y)
table.insert(dump, "Locked: " .. tostring(self.db.ui.locked))
table.insert(dump, "Show Queue: " .. tostring(self.db.ui.showQueue))
table.insert(dump, "Queue Size: " .. tostring(self.db.ui.queueSize))
table.insert(dump, "Queue Layout: " .. tostring(self.db.ui.queueLayout))
else
table.insert(dump, "UI configuration not yet initialized")
end
table.insert(dump, "")
-- Rules Configuration
table.insert(dump, "=== Rules Configuration ===")
if self.db and self.db.rules then
local enabledRules = {}
local disabledRules = {}
for rule, enabled in pairs(self.db.rules) do
if enabled then
table.insert(enabledRules, rule)
else
table.insert(disabledRules, rule)
end
end
table.sort(enabledRules)
table.sort(disabledRules)
table.insert(dump, "Enabled Rules (" .. #enabledRules .. "):")
for _, rule in ipairs(enabledRules) do
table.insert(dump, " " .. rule)
end
if #disabledRules > 0 then
table.insert(dump, "")
table.insert(dump, "Disabled Rules (" .. #disabledRules .. "):")
for _, rule in ipairs(disabledRules) do
table.insert(dump, " " .. rule)
end
end
else
table.insert(dump, "Rules configuration not yet initialized")
end
table.insert(dump, "")
-- Current State
table.insert(dump, "=== Current State ===")
local _, class = UnitClass("player")
local spec = GetSpecialization()
table.insert(dump, "Class: " .. (class or "Unknown"))
table.insert(dump, "Specialization: " .. (spec or "Unknown"))
table.insert(dump, "In Combat: " .. tostring(InCombatLockdown()))
table.insert(dump, "")
-- Debugging Tips
table.insert(dump, "=== Debugging Tips ===")
table.insert(dump, "• Use '/healiq debug' to toggle real-time debug output")
table.insert(dump, "• Use '/healiq test' to generate sample suggestions")
table.insert(dump, "• Monitor rule trigger frequencies to optimize strategy")
table.insert(dump, "• Adjust min target thresholds based on group size")
table.insert(dump, "• Check suggestion efficiency for performance insights")
table.insert(dump, "")
-- Export Instructions
table.insert(dump, "=== Export Instructions ===")
table.insert(dump, "• Click in this text area to select all content")
table.insert(dump, "• Use Ctrl+C (Cmd+C on Mac) to copy to clipboard")
table.insert(dump, "• Paste into any text editor, spreadsheet, or document")
table.insert(dump, "• Data includes all session metrics and configuration")
table.insert(dump, "• Use the Refresh button above to get latest data")
table.insert(dump, "")
return table.concat(dump, "\n")
end
-- Register Logging module with the initialization system
local function initializeLogging()
Logging:InitializeVariables()
HealIQ:DebugLog("Logging module initialized successfully", "INFO")
end
-- Register with initialization system
if HealIQ.InitRegistry then
HealIQ.InitRegistry:RegisterComponent("Logging", initializeLogging, {})
else
-- Fallback if Init.lua didn't load properly
HealIQ:DebugLog("Init system not available, using fallback initialization for Logging", "WARN")
HealIQ:SafeCall(initializeLogging)
end