Last active
August 29, 2015 14:21
-
-
Save tyriis/a5374773e6172da466a8 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
function log(value) | |
if( DEFAULT_CHAT_FRAME ) then | |
DEFAULT_CHAT_FRAME:AddMessage(value); | |
end | |
end | |
function debug(value, indent, returnResult) | |
local linePrefix = "- " | |
local typeValue = type(value) | |
local result = "" | |
local indent = indent | |
if indent == nil then | |
indent = 0 | |
result = linePrefix | |
end | |
if typeValue == "nil" then | |
result = result .. tostring(value) | |
elseif typeValue == "table" then | |
result = result .. tostring(value) .. "{\n" .. linePrefix | |
for k,v in value do | |
result = result .. string.rep(" ", indent + 1) .. "\'" .. k .. "\'" .. ": " .. debug(v, indent + 2, true) .. "\n" .. linePrefix | |
end | |
result = result .. string.rep(" ", indent) .. "}" | |
else | |
result = result .. tostring(value) .. ":" .. typeValue | |
end | |
if returnResult == true then | |
return result | |
end | |
log(result) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment