mirror of
https://github.com/nodejs/node.git
synced 2026-11-25 23:01:06 -05:00
console: add support for console.debug
Adds the console.debug() method, alias for console.log(). This method is exposed by V8 and was only available in inspector until now. Also adds matching test and documentation. PR-URL: https://github.com/nodejs/node/pull/17033 Refs: https://github.com/nodejs/node/pull/17004 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Khaidi Chu <i@2333.moe> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
1 parent
a12bc2df0e
commit
40d4fee8d7
3 files changed
+23
No files matched your search
@@ -238,6 +238,15 @@ undefined
|
||||
>
|
||||
```
|
||||
|
||||
### console.debug(data[, ...args])
|
||||
<!-- YAML
|
||||
added: v8.0.0
|
||||
-->
|
||||
* `data` {any}
|
||||
* `...args` {any}
|
||||
|
||||
The `console.debug()` function is an alias for [`console.log()`][].
|
||||
|
||||
### console.dir(obj[, options])
|
||||
<!-- YAML
|
||||
added: v0.1.101
|
||||
|
||||
@@ -134,6 +134,9 @@ Console.prototype.log = function log(...args) {
|
||||
};
|
||||
|
||||
|
||||
Console.prototype.debug = Console.prototype.log;
|
||||
|
||||
|
||||
Console.prototype.info = Console.prototype.log;
|
||||
|
||||
|
||||
|
||||
@@ -69,6 +69,13 @@ console.log('%s %s', 'foo', 'bar', 'hop');
|
||||
console.log({ slashes: '\\\\' });
|
||||
console.log(custom_inspect);
|
||||
|
||||
// test console.debug() goes to stdout
|
||||
console.debug('foo');
|
||||
console.debug('foo', 'bar');
|
||||
console.debug('%s %s', 'foo', 'bar', 'hop');
|
||||
console.debug({ slashes: '\\\\' });
|
||||
console.debug(custom_inspect);
|
||||
|
||||
// test console.info() goes to stdout
|
||||
console.info('foo');
|
||||
console.info('foo', 'bar');
|
||||
@@ -154,6 +161,10 @@ for (const expected of expectedStrings) {
|
||||
assert.strictEqual(errStrings.shift(), `${expected}\n`);
|
||||
}
|
||||
|
||||
for (const expected of expectedStrings) {
|
||||
assert.strictEqual(strings.shift(), `${expected}\n`);
|
||||
}
|
||||
|
||||
assert.strictEqual(strings.shift(),
|
||||
"{ foo: 'bar', inspect: [Function: inspect] }\n");
|
||||
assert.strictEqual(strings.shift(),
|
||||
|
||||
Reference in new issue
Block a user