Created
June 1, 2021 02:10
-
-
Save kemayo/5dd773f0592f8afebda6c40253b10314 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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