Add debug log from retail

This commit is contained in:
NoM0Re
2025-01-06 12:52:38 +01:00
parent 13ab335094
commit 873748218a
10 changed files with 309 additions and 4 deletions
+89 -1
View File
@@ -148,7 +148,7 @@ function OptionsPrivate.GetInformationOptions(data)
end
end
-- compatibility Options
-- compatibility Options
args.compabilityTitle = {
type = "header",
name = L["Compatibility Options"],
@@ -245,6 +245,94 @@ function OptionsPrivate.GetInformationOptions(data)
end
end
-- Debug Log
args.debugLogTitle = {
type = "header",
name = L["Enable Debug Log"],
width = WeakAuras.doubleWidth,
order = order,
}
order = order + 1
args.debugLogDesc = {
type = "description",
name = L["This enables the collection of debug logs. This requires custom coded auras that use DebugPrints."],
width = WeakAuras.doubleWidth,
order = order,
}
order = order + 1
local sameDebugLog = true
local commonDebugLog
local debugLogDesc = ""
for child in OptionsPrivate.Private.TraverseLeafsOrAura(data) do
local effectiveDebugLog = child.information.debugLog and true or false
debugLogDesc = debugLogDesc .. "|cFFE0E000"..child.id..": |r".. (effectiveDebugLog and "true" or "false") .. "\n"
if commonDebugLog == nil then
commonDebugLog = effectiveDebugLog
elseif effectiveDebugLog ~= commonDebugLog then
sameDebugLog = false
end
end
args.debugLogToggle = {
type = "toggle",
name = sameDebugLog and L["Enable Debug Logging"] or "|cFF4080FF" .. L["Enable Debug Logging"],
desc = not sameDebugLog and debugLogDesc or nil,
width = WeakAuras.doubleWidth,
order = order,
get = function()
return sameDebugLog and commonDebugLog
end,
set = function(info, v)
for child in OptionsPrivate.Private.TraverseLeafsOrAura(data) do
child.information.debugLog = v
WeakAuras.Add(child)
OptionsPrivate.ClearOptions(child.id)
end
WeakAuras.ClearAndUpdateOptions(data.id)
end
}
order = order + 1
if not sameDebugLog or commonDebugLog then
args.debugLogShow = {
type = "execute",
name = L["Show Debug Logs"],
width = WeakAuras.normalWidth,
order = order,
func = function()
local fullMessage = L["WeakAuras %s on WoW %s"]:format(WeakAuras.versionString, WeakAuras.BuildInfo) .. "\n\n"
local haveLogs = false
for child in OptionsPrivate.Private.TraverseLeafsOrAura(data) do
local auraLog = OptionsPrivate.Private.DebugLog.GetLogs(child.uid)
if auraLog then
haveLogs = true
fullMessage = fullMessage .. L["Aura: '%s'"]:format(child.id)
local version = child.semver or child.version
if (version) then
fullMessage = fullMessage .. "\n" .. L["Version: %s"]:format(version)
end
fullMessage = fullMessage .. "\n" .. L["Debug Log:"] .. "\n" .. auraLog .. "\n\n"
end
end
if haveLogs then
OptionsPrivate.OpenDebugLog(fullMessage)
else
OptionsPrivate.OpenDebugLog(L["No Logs saved."])
end
end
}
order = order + 1
args.debugLogClear = {
type = "execute",
name = L["Clear Debug Logs"],
width = WeakAuras.normalWidth,
order = order,
func = function()
for child in OptionsPrivate.Private.TraverseLeafsOrAura(data) do
OptionsPrivate.Private.DebugLog.Clear(child.uid)
end
end
}
order = order + 1
end
return options
end
@@ -0,0 +1,71 @@
if not WeakAuras.IsCorrectVersion() or not WeakAuras.IsLibsOK() then return end
local AddonName, OptionsPrivate = ...
-- WoW APIs
local CreateFrame = CreateFrame
local AceGUI = LibStub("AceGUI-3.0")
local WeakAuras = WeakAuras
local L = WeakAuras.L
local debugLog
local function ConstructDebugLog(frame)
local group = AceGUI:Create("WeakAurasInlineGroup");
group.frame:SetParent(frame);
group.frame:SetPoint("TOPLEFT", frame, "TOPLEFT", 17, -63);
group.frame:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -17, 46);
group.frame:Hide();
group:SetLayout("flow");
local copyLabel = AceGUI:Create("Label")
copyLabel:SetFontObject(GameFontNormal)
copyLabel:SetFullWidth(true)
copyLabel:SetText(L["Press Ctrl+C to copy"])
group:AddChild(copyLabel)
local input = AceGUI:Create("MultiLineEditBox");
input:DisableButton(true)
--input.frame:SetClipsChildren(true);
input.editBox:SetScript("OnEscapePressed", function() group:Close(); end);
input.editBox:SetScript("OnMouseUp", function() input.editBox:HighlightText(); end);
input:SetFullWidth(true)
input:SetFullHeight(true)
group:AddChild(input);
local close = CreateFrame("Button", nil, group.frame, "UIPanelButtonTemplate");
close:SetScript("OnClick", function() group:Close() end);
close:SetPoint("BOTTOMRIGHT", -20, -24)
close:SetFrameLevel(close:GetFrameLevel() + 1)
close:SetHeight(20);
close:SetWidth(100);
close:SetText(L["Close"])
function group.Open(self, text)
frame.window = "debuglog";
frame:UpdateFrameVisible()
input.editBox:SetScript("OnTextChanged", function() input:SetText(text); input.editBox:HighlightText(); end);
input.editBox:SetScript("OnMouseUp", function() input.editBox:HighlightText(); end);
input:SetLabel("");
input.button:Hide();
input:SetText(text);
input.editBox:HighlightText();
input:SetFocus()
group:DoLayout()
end
function group.Close(self)
input:ClearFocus();
frame.window = "default";
frame:UpdateFrameVisible()
end
return group
end
function OptionsPrivate.DebugLog(frame)
debugLog = debugLog or ConstructDebugLog(frame)
return debugLog
end
@@ -212,6 +212,7 @@ function OptionsPrivate.CreateFrame()
self.update.frame:Hide()
self.texteditor.frame:Hide()
self.codereview.frame:Hide()
self.debugLog.frame:Hide()
if self.newView then
self.newView.frame:Hide()
end
@@ -292,6 +293,12 @@ function OptionsPrivate.CreateFrame()
else
self.update.frame:Hide()
end
if self.window == "debuglog" then
OptionsPrivate.SetTitle(L["Debug Log"])
self.debugLog.frame:Show()
else
self.debugLog.frame:Hide()
end
if self.window == "default" then
if self.loadProgessVisible then
self.loadProgress:Show()
@@ -486,6 +493,7 @@ function OptionsPrivate.CreateFrame()
frame.texteditor = OptionsPrivate.TextEditor(frame)
frame.codereview = OptionsPrivate.CodeReview(frame)
frame.update = OptionsPrivate.UpdateFrame(frame)
frame.debugLog = OptionsPrivate.DebugLog(frame)
frame.moversizer, frame.mover = OptionsPrivate.MoverSizer(frame)
+4
View File
@@ -892,6 +892,10 @@ function OptionsPrivate.ImportFromString()
frame.importexport:Open("import");
end
function OptionsPrivate.OpenDebugLog(text)
frame.debugLog:Open(text)
end
function OptionsPrivate.OpenUpdate(data, children, target, sender)
return frame.update:Open(data, children, target, sender)
end
+1
View File
@@ -65,6 +65,7 @@ OptionsFrames\ModelPicker.lua
OptionsFrames\TextEditor.lua
OptionsFrames\TexturePicker.lua
OptionsFrames\Update.lua
OptionsFrames\DebugLogFrame.lua
# Misc frames
OptionsFrames\MoverSizer.lua