@@ -79,17 +79,22 @@ const { Console } = console;
79
79
```
80
80
81
81
### new Console(stdout[ , stderr] [ , ignoreErrors ] )
82
+ ### new Console(options)
82
83
<!-- YAML
83
84
changes:
84
85
- version: v8.0.0
85
86
pr-url: https://github.com/nodejs/node/pull/9744
86
87
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.
87
91
-->
88
92
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 ` .
93
98
94
99
Creates a new ` Console ` with one or two writable stream instances. ` stdout ` is a
95
100
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`.
99
104
const output = fs .createWriteStream (' ./stdout.log' );
100
105
const errorOutput = fs .createWriteStream (' ./stderr.log' );
101
106
// custom simple logger
102
- const logger = new Console (output, errorOutput);
107
+ const logger = new Console ({ stdout : output, stderr : errorOutput } );
103
108
// use it like console
104
109
const count = 5 ;
105
110
logger .log (' count: %d' , count);
@@ -110,7 +115,7 @@ The global `console` is a special `Console` whose output is sent to
110
115
[ ` process.stdout ` ] [ ] and [ ` process.stderr ` ] [ ] . It is equivalent to calling:
111
116
112
117
``` js
113
- new Console (process .stdout , process .stderr );
118
+ new Console ({ stdout : process .stdout , stderr : process .stderr } );
114
119
```
115
120
116
121
### console.assert(value[ , ...message] )
0 commit comments