console: use a plain object for the the error stack
Using a object instead of an Error is sufficient as the Error itself won't be used but only the stack trace that would otherwise be created twice. This improves the overall .trace() performance. PR-URL: https://github.com/nodejs/node/pull/13743 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Refael Ackermann <refack@gmail.com>
This commit is contained in:
parent
3e178848a5
commit
70b31adffa
@ -151,11 +151,10 @@ Console.prototype.timeEnd = function timeEnd(label) {
|
||||
|
||||
|
||||
Console.prototype.trace = function trace(...args) {
|
||||
// TODO probably can to do this better with V8's debug object once that is
|
||||
// exposed.
|
||||
var err = new Error();
|
||||
err.name = 'Trace';
|
||||
err.message = util.format.apply(null, args);
|
||||
const err = {
|
||||
name: 'Trace',
|
||||
message: util.format.apply(null, args)
|
||||
};
|
||||
Error.captureStackTrace(err, trace);
|
||||
this.error(err.stack);
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user