comparison Core.lua @ 169:d367da49a490

Debug function can now print tables.
author Zerotorescue
date Tue, 25 Jan 2011 10:11:09 +0100
parents e136c99fe5bb
children 26c750a10b14
comparison
equal deleted inserted replaced
168:6065f48e4e47 169:d367da49a490
505 return itemLink; 505 return itemLink;
506 end 506 end
507 507
508 -- Debug 508 -- Debug
509 509
510 local function ReadableTable(t)
511 local temp = "";
512
513 for i, v in pairs(t) do
514 temp = temp .. " {";
515 if type(v) == "table" then
516 temp = temp .. ReadableTable(v) .. ",";
517 else
518 temp = temp .. tostring(v) .. ",";
519 end
520 temp = temp .. "}";
521 end
522
523 return temp;
524 end
525
510 function addon:Debug(t, ...) 526 function addon:Debug(t, ...)
511 if not self.debugChannel and self.debugChannel ~= false then 527 if not self.debugChannel and self.debugChannel ~= false then
512 -- We want to check just once, so if you add a debug channel later just do a /reload (registering an event for this is wasted resources) 528 -- We want to check just once, so if you add a debug channel later just do a /reload (registering an event for this is wasted resources)
513 self.debugChannel = false; 529 self.debugChannel = false;
514 530
520 end 536 end
521 end 537 end
522 end 538 end
523 539
524 if self.debugChannel then 540 if self.debugChannel then
541 if type(t) == "table" then
542 t = ReadableTable(t);
543 end
544
525 self.debugChannel:AddMessage("|cffffff00Inventorium|r:" .. sformat(t, ...)); 545 self.debugChannel:AddMessage("|cffffff00Inventorium|r:" .. sformat(t, ...));
526 end 546 end
527 end 547 end