Skip to content

Instantly share code, notes, and snippets.

@kemayo
Created June 1, 2021 02:10
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kemayo/5dd773f0592f8afebda6c40253b10314 to your computer and use it in GitHub Desktop.
Save kemayo/5dd773f0592f8afebda6c40253b10314 to your computer and use it in GitHub Desktop.
local myname, ns = ...
local Debug
do
local TextDump = LibStub("LibTextDump-1.0")
local debuggable = GetAddOnMetadata(myname, "Version") == '@project-version@'
local _window
local function GetDebugWindow()
if not _window then
_window = TextDump:New(myname)
end
return _window
end
ns.Debug = function(...)
if not debuggable then return end
-- if debugf then debugf:AddMessage(string.join(", ", tostringall(...))) end
GetDebugWindow():AddLine(string.join(', ', tostringall(...)))
end
ns.DebugF = function(...)
if not debuggable then return end
Debug(string.format(...))
end
function ns:ShowDebugWindow()
local window = self.GetDebugWindow()
if window:Lines() == 0 then
window:AddLine("Nothing has happened yet")
window:Display()
window:Clear()
return
end
window:Display()
end
ns.debuggable = debuggable
Debug = ns.Debug
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment