- 时间:2021-08-30 00:52 编辑: 来源: 阅读:
- 扫一扫,手机访问
摘要:node.js中的console.trace方法使用说明
[b]方法说明:[/b]
向标准错误流输出当前的调用栈。
[b]语法:[/b]
console.trace(label)
[b]接收参数:[/b]
label
[b]例子:[/b]
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)
[b]源码:[/b]
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);
};