You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Love this project! Sorry if this has already been covered... I did take a look at the issue list and found mostly people saying not implemented, or suggesting browser related solutions. I'm working in NodeJS, and having a function name and line number on each debug message really helps development efforts.
I'm wondering what the implications of adding the following which I've just started using in a recent NodeJS project? Especially the use of arguments.callee which I've read is depreciated. Is there an alternative?
I would love to be able to turn this on as an option, rather than have to append it to every debug message as shown below.
const debug = require('debug')('MyApp:MyModule')
debug(__dstring + "My debug message")
Outputs: MyApp:MyModule myFunction 44 My debug message
__dstring is defined like this:
Object.defineProperty(global, '__dstring', {
get: function () {
try {
var orig = Error.prepareStackTrace;
Error.prepareStackTrace = function (_, stack) {
return stack;
};
var err = new Error;
Error.captureStackTrace(err, arguments.callee);
var stack = err.stack;
Error.prepareStackTrace = orig;
return stack[1].getMethodName() + " " + stack[1].getLineNumber() + " ";
} catch (err) {
return ""
}
}
});
Hi All,
Love this project! Sorry if this has already been covered... I did take a look at the issue list and found mostly people saying not implemented, or suggesting browser related solutions. I'm working in NodeJS, and having a function name and line number on each debug message really helps development efforts.
I'm wondering what the implications of adding the following which I've just started using in a recent NodeJS project? Especially the use of arguments.callee which I've read is depreciated. Is there an alternative?
I would love to be able to turn this on as an option, rather than have to append it to every debug message as shown below.
Outputs:
MyApp:MyModule myFunction 44 My debug message
__dstring is defined like this:
References:
http://stackoverflow.com/questions/11386492/accessing-line-number-in-v8-javascript-chrome-node-js
The text was updated successfully, but these errors were encountered: