@@ -79,17 +79,22 @@ const { Console } = console;
7979```
8080
8181### new Console(stdout[ , stderr] [ , ignoreErrors ] )
82+ ### new Console(options)
8283<!-- YAML
8384changes:
8485 - version: v8.0.0
8586 pr-url: https://github.com/nodejs/node/pull/9744
8687 description: The `ignoreErrors` option was introduced.
88+ - version: REPLACEME
89+ pr-url: https://github.com/nodejs/node/pull/19372
90+ description: The `Console` constructor now supports an `options` argument.
8791-->
8892
89- * ` stdout ` {stream.Writable}
90- * ` stderr ` {stream.Writable}
91- * ` ignoreErrors ` {boolean} Ignore errors when writing to the underlying streams.
92- Defaults to ` true ` .
93+ * ` options ` {Object}
94+ * ` stdout ` {stream.Writable}
95+ * ` stderr ` {stream.Writable}
96+ * ` ignoreErrors ` {boolean} Ignore errors when writing to the underlying
97+ streams. ** Default:** ` true ` .
9398
9499Creates a new ` Console ` with one or two writable stream instances. ` stdout ` is a
95100writable 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`.
99104const output = fs .createWriteStream (' ./stdout.log' );
100105const errorOutput = fs .createWriteStream (' ./stderr.log' );
101106// custom simple logger
102- const logger = new Console (output, errorOutput);
107+ const logger = new Console ({ stdout : output, stderr : errorOutput } );
103108// use it like console
104109const count = 5 ;
105110logger .log (' count: %d' , count);
@@ -110,7 +115,7 @@ The global `console` is a special `Console` whose output is sent to
110115[ ` process.stdout ` ] [ ] and [ ` process.stderr ` ] [ ] . It is equivalent to calling:
111116
112117``` js
113- new Console (process .stdout , process .stderr );
118+ new Console ({ stdout : process .stdout , stderr : process .stderr } );
114119```
115120
116121### console.assert(value[ , ...message] )
0 commit comments