From ce58df58d0360779d16d60ce3bb0e9979ec5fdf4 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Sat, 17 Mar 2018 12:53:09 +0100 Subject: console: allow `options` object as constructor arg PR-URL: https://github.com/nodejs/node/pull/19372 Reviewed-By: Luigi Pinca Reviewed-By: James M Snell --- doc/api/console.md | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'doc/api/console.md') diff --git a/doc/api/console.md b/doc/api/console.md index db3a903eaf..99c31df242 100644 --- a/doc/api/console.md +++ b/doc/api/console.md @@ -79,17 +79,22 @@ const { Console } = console; ``` ### new Console(stdout[, stderr][, ignoreErrors]) +### new Console(options) -* `stdout` {stream.Writable} -* `stderr` {stream.Writable} -* `ignoreErrors` {boolean} Ignore errors when writing to the underlying streams. - Defaults to `true`. +* `options` {Object} + * `stdout` {stream.Writable} + * `stderr` {stream.Writable} + * `ignoreErrors` {boolean} Ignore errors when writing to the underlying + streams. **Default:** `true`. Creates a new `Console` with one or two writable stream instances. `stdout` is a writable stream to print log or info output. `stderr` is used for warning or @@ -99,7 +104,7 @@ error output. If `stderr` is not provided, `stdout` is used for `stderr`. const output = fs.createWriteStream('./stdout.log'); const errorOutput = fs.createWriteStream('./stderr.log'); // custom simple logger -const logger = new Console(output, errorOutput); +const logger = new Console({ stdout: output, stderr: errorOutput }); // use it like console const count = 5; logger.log('count: %d', count); @@ -110,7 +115,7 @@ The global `console` is a special `Console` whose output is sent to [`process.stdout`][] and [`process.stderr`][]. It is equivalent to calling: ```js -new Console(process.stdout, process.stderr); +new Console({ stdout: process.stdout, stderr: process.stderr }); ``` ### console.assert(value[, ...message]) -- cgit v1.2.3