add LvDEBUG

so we can get rid of stack overflow when dumping a widget
pull/2/merge
Qingping Hou 11 years ago
parent c9c72522b9
commit 24400c06e6

@ -21,10 +21,14 @@ function Dbg:logEv(ev)
end
function DEBUG(...)
LvDEBUG(math.huge, ...)
end
function LvDEBUG(lv, ...)
local line = ""
for i,v in ipairs({...}) do
if type(v) == "table" then
line = line .. " " .. dump(v)
line = line .. " " .. dump(v, lv)
else
line = line .. " " .. tostring(v)
end
@ -32,5 +36,3 @@ function DEBUG(...)
print("#"..line)
end

@ -64,14 +64,22 @@ function DocSettings:delSetting(key)
self.data[key] = nil
end
function dump(data)
function dump(data, max_lv)
local out = {}
DocSettings:_serialize(data, out, 0)
DocSettings:_serialize(data, out, 0, max_lv)
return table.concat(out)
end
-- simple serialization function, won't do uservalues, functions, loops
function DocSettings:_serialize(what, outt, indent)
function DocSettings:_serialize(what, outt, indent, max_lv)
if not max_lv then
max_lv = math.huge
end
if indent > max_lv then
return
end
if type(what) == "table" then
local didrun = false
table.insert(outt, "{")
@ -82,9 +90,9 @@ function DocSettings:_serialize(what, outt, indent)
table.insert(outt, "\n")
table.insert(outt, string.rep("\t", indent+1))
table.insert(outt, "[")
self:_serialize(k, outt, indent+1)
self:_serialize(k, outt, indent+1, max_lv)
table.insert(outt, "] = ")
self:_serialize(v, outt, indent+1)
self:_serialize(v, outt, indent+1, max_lv)
didrun = true
end
if didrun then

Loading…
Cancel
Save