Skip to content

Commit 40d4fee

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 a12bc2d commit 40d4fee

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

doc/api/console.md

+9
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,15 @@ undefined
238238
>
239239
```
240240

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

lib/console.js

+3
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,9 @@ Console.prototype.log = function log(...args) {
134134
};
135135

136136

137+
Console.prototype.debug = Console.prototype.log;
138+
139+
137140
Console.prototype.info = Console.prototype.log;
138141

139142

test/parallel/test-console.js

+11
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,13 @@ console.log('%s %s', 'foo', 'bar', 'hop');
6969
console.log({ slashes: '\\\\' });
7070
console.log(custom_inspect);
7171

72+
// test console.debug() goes to stdout
73+
console.debug('foo');
74+
console.debug('foo', 'bar');
75+
console.debug('%s %s', 'foo', 'bar', 'hop');
76+
console.debug({ slashes: '\\\\' });
77+
console.debug(custom_inspect);
78+
7279
// test console.info() goes to stdout
7380
console.info('foo');
7481
console.info('foo', 'bar');
@@ -154,6 +161,10 @@ for (const expected of expectedStrings) {
154161
assert.strictEqual(errStrings.shift(), `${expected}\n`);
155162
}
156163

164+
for (const expected of expectedStrings) {
165+
assert.strictEqual(strings.shift(), `${expected}\n`);
166+
}
167+
157168
assert.strictEqual(strings.shift(),
158169
"{ foo: 'bar', inspect: [Function: inspect] }\n");
159170
assert.strictEqual(strings.shift(),

0 commit comments

Comments
 (0)