RedJini Blog

뒤로 검색

[node.js] traceback

2013/10/22 11:53

셈플

var traceback = require("traceback");

function start() { first() }
function first() { second() }
var second = function() { last() }

function last() {
  var stack = traceback();
  console.log("I am " + stack[0].name + " from file " + stack[0].file)

  for(var i = 1; i <= 3; i++)
    console.log("  " + i + " above me: " + stack[i].name 
                         + " at line " + stack[i].line+" path "+stack[i].path);
}
start();

실행 결과

[root@redjini source]# ../bin/node test.js
I am last from file test.js
  1 above me: second at line 5 path /data/NodeJS/source/test.js
  2 above me: first at line 4 path /data/NodeJS/source/test.js
  3 above me: start at line 3 path /data/NodeJS/source/test.js

참고 :

Tags

NodeJS, stacktrace, traceback
이 페이지는 Textcube 1.9.3 : poco a poco 로 구동됩니다 데스크탑 화면