[node.js] traceback

셈플

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

참고 :

2013/10/22 11:53 2013/10/22 11:53
글 걸기 주소 : 이 글에는 트랙백을 보낼 수 없습니다