node.js中的console.trace方法使用说明

时间:2014-12-09    点击:67   

方法说明:

向标准错误流输出当前的调用栈。

语法:

复制代码 代码如下:

console.trace(label)

接收参数:

label

例子:

复制代码 代码如下:

console.trace();
 
//运行结果:
Trace:
     at Object.<anonymous> (/home/byvoid/consoletrace.js : 1: 71)
     at Module._compile (module.js:441:26)
     at Object..js (module.js:459:10)
     at Module.load (module.js:348:31)
     at Function._load (module.js:308:12)
     at Array.0 (module.js:479:10)
     at EventEmitter._tickCallback (node.js:192:40)

源码:

复制代码 代码如下:

Console.prototype.trace = function() {
  // 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 = util.format.apply(this, arguments);
  Error.captureStackTrace(err, arguments.callee);
  this.error(err.stack);
};

基于javascript实现判断移动终端浏览器版本信息
node.js中的console.log方法使用说明
node.js中的console.warn方法使用说明
node.js中的console.info方法使用说明
浅谈JavaScript实现面向对象中的类
> 返回     
地址:上海市普陀区胶州路941号长久商务中心 电话: QQ:
© Copyright 2012 上海网络 Product All Rights Reserved