Skip to content

Instantly share code, notes, and snippets.

@tyriis
Last active August 29, 2015 14:21
Show Gist options
  • Save tyriis/a5374773e6172da466a8 to your computer and use it in GitHub Desktop.
Save tyriis/a5374773e6172da466a8 to your computer and use it in GitHub Desktop.
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