diff options
author | Ruben Bridgewater <ruben@bridgewater.de> | 2020-05-22 15:02:04 +0300 |
---|---|---|
committer | Ruben Bridgewater <ruben@bridgewater.de> | 2020-05-30 05:19:27 +0300 |
commit | 4bdab881b8cdfdc53e90267e549ff2c8b9ab310b (patch) | |
tree | 381d601b68575726f9d92a9e41948dc1edf5979d /lib/internal/console | |
parent | 87629d7e7c793fe4b452e6818c2b033d07ce1f44 (diff) |
console: name console functions appropriately
The current name of most of the global console functions is
"bound consoleCall". This is changed to the actual functions name
e.g., "log" or "error".
Signed-off-by: Ruben Bridgewater <ruben@bridgewater.de>
PR-URL: https://github.com/nodejs/node/pull/33524
Reviewed-By: Michaƫl Zasso <targos@protonmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
Diffstat (limited to 'lib/internal/console')
-rw-r--r-- | lib/internal/console/constructor.js | 3 | ||||
-rw-r--r-- | lib/internal/console/global.js | 2 |
2 files changed, 5 insertions, 0 deletions
diff --git a/lib/internal/console/constructor.js b/lib/internal/console/constructor.js index bdb8a84b94c..458a5cd2738 100644 --- a/lib/internal/console/constructor.js +++ b/lib/internal/console/constructor.js @@ -136,6 +136,9 @@ function Console(options /* or: stdout, stderr, ignoreErrors = true */) { // the prototype so that users extending the Console can override them // from the prototype chain of the subclass. this[key] = this[key].bind(this); + ObjectDefineProperty(this[key], 'name', { + value: key + }); } this[kBindStreamsEager](stdout, stderr); diff --git a/lib/internal/console/global.js b/lib/internal/console/global.js index 6a1dc3806fd..1c615c78451 100644 --- a/lib/internal/console/global.js +++ b/lib/internal/console/global.js @@ -36,7 +36,9 @@ for (const prop of ReflectOwnKeys(Console.prototype)) { if (prop === 'constructor') { continue; } const desc = ReflectGetOwnPropertyDescriptor(Console.prototype, prop); if (typeof desc.value === 'function') { // fix the receiver + const name = desc.value.name; desc.value = desc.value.bind(globalConsole); + ReflectDefineProperty(desc.value, 'name', { value: name }); } ReflectDefineProperty(globalConsole, prop, desc); } |