简体   繁体   English

Node.js Express-记录退出时输入的最后一个方法

[英]Node.js Express - logging last method entered upon exit

Is there a clever way to log the last few functions/methods my Node.js program was in when it decided to exit? 当决定退出时,是否有一种聪明的方法来记录我的Node.js程序所处的最后几个功能/方法?

you can use 您可以使用

 process.on('exit',function(code){
  console.log('exit code:',code);
});

but all I have is the exit code - how to get stacktrace? 但我只有出口代码-如何获取stacktrace?

http://nodejs.org/api/process.html#process_event_exit http://nodejs.org/api/process.html#process_event_exit

Dump a stacktrace: 转储堆栈跟踪:

process.on('exit',function(code) { 
    var stack = new Error().stack
    console.log( stack )
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM