diff --git a/canvas.js b/canvas.js index 027a0ac..92acc9c 100644 --- a/canvas.js +++ b/canvas.js @@ -6,16 +6,21 @@ function debug(str) { function dirObj(obj, parent, depth) { var msg = ""; - if (! depth) { depth=0; } + var val = ""; + if (! depth) { depth=2; } if (! parent) { parent= ""; } // Print the properties of the passed-in object for (var i in obj) { - if ((depth < 2) && (typeof obj[i] == "object")) { + if ((depth > 1) && (typeof obj[i] == "object")) { // Recurse attributes that are objects - msg += dirObj(obj[i], parent + "." + i, depth+1); + msg += dirObj(obj[i], parent + "." + i, depth-1); } else { - msg += parent + "." + i + ": " + obj[i] + "\n"; + val = new String(obj[i]).replace("\n", " "); + if (val.length > 30) { + val = val.substr(0,30) + "..."; + } + msg += parent + "." + i + ": " + val + "\n"; } } return msg;