I\'m working on enhancing logging in some node.js applications. In the past have used C++\'s __ file__ and __ line __ preprocessor macros to help us track down issues when
See: Accessing line number in V8 JavaScript (Chrome & Node.js)
Then for a filename:
Object.defineProperty(global, '__file', {
get: function(){
return __stack[1].getFileName().split('/').slice(-1)[0];
}
});
You could also just use the process.argv[1]
instead of calling the __stack
getter but I wanted to keep it similar.