Skip to content

Commit 162ff56

Browse files
TirielMylesBorins
authored andcommitted
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: #17033 Refs: #17004 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Khaidi Chu <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Timothy Gu <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 22d4fef commit 162ff56

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

doc/api/console.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,15 @@ undefined
237237
>
238238
```
239239

240+
### console.debug(data[, ...args])
241+
<!-- YAML
242+
added: v8.0.0
243+
-->
244+
* `data` {any}
245+
* `...args` {any}
246+
247+
The `console.debug()` function is an alias for [`console.log()`][].
248+
240249
### console.dir(obj[, options])
241250
<!-- YAML
242251
added: v0.1.101

lib/console.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,9 @@ Console.prototype.log = function log(...args) {
133133
};
134134

135135

136+
Console.prototype.debug = Console.prototype.log;
137+
138+
136139
Console.prototype.info = Console.prototype.log;
137140

138141

test/parallel/test-console.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,13 @@ console.log('%s %s', 'foo', 'bar', 'hop');
6161
console.log({ slashes: '\\\\' });
6262
console.log(custom_inspect);
6363

64+
// test console.debug() goes to stdout
65+
console.debug('foo');
66+
console.debug('foo', 'bar');
67+
console.debug('%s %s', 'foo', 'bar', 'hop');
68+
console.debug({ slashes: '\\\\' });
69+
console.debug(custom_inspect);
70+
6471
// test console.info() goes to stdout
6572
console.info('foo');
6673
console.info('foo', 'bar');
@@ -132,6 +139,10 @@ for (const expected of expectedStrings) {
132139
assert.strictEqual(errStrings.shift(), `${expected}\n`);
133140
}
134141

142+
for (const expected of expectedStrings) {
143+
assert.strictEqual(strings.shift(), `${expected}\n`);
144+
}
145+
135146
assert.strictEqual(strings.shift(),
136147
"{ foo: 'bar', inspect: [Function: inspect] }\n");
137148
assert.strictEqual(strings.shift(),

0 commit comments

Comments
 (0)