From e8795cea30436aad5b88b6885c60b543b35c4162 Mon Sep 17 00:00:00 2001 From: Tj Holowaychuk Date: Thu, 5 Aug 2010 10:47:26 -0700 Subject: [PATCH] Added console.trace() --- src/node.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/node.js b/src/node.js index 8c5b3a0..a5d8d07 100644 --- a/src/node.js +++ b/src/node.js @@ -247,6 +247,16 @@ global.console.timeEnd = function(label){ global.console.log('%s: %dms', label, duration); }; +global.console.trace = function(label){ + // TODO probably can to do this better with V8's debug object once that is + // exposed. + var err = new Error; + err.name = 'Trace'; + err.message = label || ''; + Error.captureStackTrace(err, arguments.callee); + console.error(err.stack); +}; + global.console.assert = function(expression){ if(!expression){ var arr = Array.prototype.slice.call(arguments, 1); -- 2.7.4