Added console.trace()
authorTj Holowaychuk <tj@vision-media.ca>
Thu, 5 Aug 2010 17:47:26 +0000 (10:47 -0700)
committerRyan Dahl <ry@tinyclouds.org>
Fri, 6 Aug 2010 19:15:04 +0000 (12:15 -0700)
src/node.js

index 8c5b3a0..a5d8d07 100644 (file)
@@ -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);