From ec3638d9a8338d024f296e3114dc24c07beedc33 Mon Sep 17 00:00:00 2001 From: Benjamin Zaslavsky Date: Tue, 14 Nov 2017 23:59:57 +0100 Subject: [PATCH 1/2] console: add support for console.debug method 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. Refs: https://github.com/nodejs/node/pull/17004#pullrequestreview-76600095 --- lib/console.js | 3 +++ test/parallel/test-console.js | 11 +++++++++++ 2 files changed, 14 insertions(+) diff --git a/lib/console.js b/lib/console.js index 2304a6668790de..4ac0634eee221b 100644 --- a/lib/console.js +++ b/lib/console.js @@ -134,6 +134,9 @@ Console.prototype.log = function log(...args) { }; +Console.prototype.debug = Console.prototype.log; + + Console.prototype.info = Console.prototype.log; diff --git a/test/parallel/test-console.js b/test/parallel/test-console.js index b3d3dedb72e9bf..eadb3a32a19ebf 100644 --- a/test/parallel/test-console.js +++ b/test/parallel/test-console.js @@ -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(), From 384a60edd9f7963ad6225ede33b1b23309c0bab1 Mon Sep 17 00:00:00 2001 From: Benjamin Zaslavsky Date: Thu, 16 Nov 2017 05:03:38 +0100 Subject: [PATCH 2/2] doc: adding description for console.debug Removed this description from PR #17004 and included in this PR following review requesting changes. Fixes: https://github.com/nodejs/node/pull/17033#pullrequestreview-76970603 Refs: https://github.com/nodejs/node/pull/17004#pullrequestreview-76600095 --- doc/api/console.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/doc/api/console.md b/doc/api/console.md index 8a9ca1ac8614fe..54d86cea161feb 100644 --- a/doc/api/console.md +++ b/doc/api/console.md @@ -238,6 +238,15 @@ undefined > ``` +### console.debug(data[, ...args]) + +* `data` {any} +* `...args` {any} + +The `console.debug()` function is an alias for [`console.log()`][]. + ### console.dir(obj[, options])