1{ 2 "type": "module", 3 "source": "doc/api/console.md", 4 "modules": [ 5 { 6 "textRaw": "Console", 7 "name": "console", 8 "introduced_in": "v0.10.13", 9 "stability": 2, 10 "stabilityText": "Stable", 11 "desc": "<p><strong>Source Code:</strong> <a href=\"https://github.com/nodejs/node/blob/v14.20.1/lib/console.js\">lib/console.js</a></p>\n<p>The <code>console</code> module provides a simple debugging console that is similar to the\nJavaScript console mechanism provided by web browsers.</p>\n<p>The module exports two specific components:</p>\n<ul>\n<li>A <code>Console</code> class with methods such as <code>console.log()</code>, <code>console.error()</code> and\n<code>console.warn()</code> that can be used to write to any Node.js stream.</li>\n<li>A global <code>console</code> instance configured to write to <a href=\"process.html#process_process_stdout\"><code>process.stdout</code></a> and\n<a href=\"process.html#process_process_stderr\"><code>process.stderr</code></a>. The global <code>console</code> can be used without calling\n<code>require('console')</code>.</li>\n</ul>\n<p><em><strong>Warning</strong></em>: The global console object's methods are neither consistently\nsynchronous like the browser APIs they resemble, nor are they consistently\nasynchronous like all other Node.js streams. See the <a href=\"process.html#process_a_note_on_process_i_o\">note on process I/O</a> for\nmore information.</p>\n<p>Example using the global <code>console</code>:</p>\n<pre><code class=\"language-js\">console.log('hello world');\n// Prints: hello world, to stdout\nconsole.log('hello %s', 'world');\n// Prints: hello world, to stdout\nconsole.error(new Error('Whoops, something bad happened'));\n// Prints error message and stack trace to stderr:\n// Error: Whoops, something bad happened\n// at [eval]:5:15\n// at Script.runInThisContext (node:vm:132:18)\n// at Object.runInThisContext (node:vm:309:38)\n// at node:internal/process/execution:77:19\n// at [eval]-wrapper:6:22\n// at evalScript (node:internal/process/execution:76:60)\n// at node:internal/main/eval_string:23:3\n\nconst name = 'Will Robinson';\nconsole.warn(`Danger ${name}! Danger!`);\n// Prints: Danger Will Robinson! Danger!, to stderr\n</code></pre>\n<p>Example using the <code>Console</code> class:</p>\n<pre><code class=\"language-js\">const out = getStreamSomehow();\nconst err = getStreamSomehow();\nconst myConsole = new console.Console(out, err);\n\nmyConsole.log('hello world');\n// Prints: hello world, to out\nmyConsole.log('hello %s', 'world');\n// Prints: hello world, to out\nmyConsole.error(new Error('Whoops, something bad happened'));\n// Prints: [Error: Whoops, something bad happened], to err\n\nconst name = 'Will Robinson';\nmyConsole.warn(`Danger ${name}! Danger!`);\n// Prints: Danger Will Robinson! Danger!, to err\n</code></pre>", 12 "classes": [ 13 { 14 "textRaw": "Class: `Console`", 15 "type": "class", 16 "name": "Console", 17 "meta": { 18 "changes": [ 19 { 20 "version": "v8.0.0", 21 "pr-url": "https://github.com/nodejs/node/pull/9744", 22 "description": "Errors that occur while writing to the underlying streams will now be ignored by default." 23 } 24 ] 25 }, 26 "desc": "<p>The <code>Console</code> class can be used to create a simple logger with configurable\noutput streams and can be accessed using either <code>require('console').Console</code>\nor <code>console.Console</code> (or their destructured counterparts):</p>\n<pre><code class=\"language-js\">const { Console } = require('console');\n</code></pre>\n<pre><code class=\"language-js\">const { Console } = console;\n</code></pre>", 27 "methods": [ 28 { 29 "textRaw": "`console.assert(value[, ...message])`", 30 "type": "method", 31 "name": "assert", 32 "meta": { 33 "added": [ 34 "v0.1.101" 35 ], 36 "changes": [ 37 { 38 "version": "v10.0.0", 39 "pr-url": "https://github.com/nodejs/node/pull/17706", 40 "description": "The implementation is now spec compliant and does not throw anymore." 41 } 42 ] 43 }, 44 "signatures": [ 45 { 46 "params": [ 47 { 48 "textRaw": "`value` {any} The value tested for being truthy.", 49 "name": "value", 50 "type": "any", 51 "desc": "The value tested for being truthy." 52 }, 53 { 54 "textRaw": "`...message` {any} All arguments besides `value` are used as error message.", 55 "name": "...message", 56 "type": "any", 57 "desc": "All arguments besides `value` are used as error message." 58 } 59 ] 60 } 61 ], 62 "desc": "<p><code>console.assert()</code> writes a message if <code>value</code> is <a href=\"https://developer.mozilla.org/en-US/docs/Glossary/Falsy\">falsy</a> or omitted. It only\nwrites a message and does not otherwise affect execution. The output always\nstarts with <code>\"Assertion failed\"</code>. If provided, <code>message</code> is formatted using\n<a href=\"util.html#util_util_format_format_args\"><code>util.format()</code></a>.</p>\n<p>If <code>value</code> is <a href=\"https://developer.mozilla.org/en-US/docs/Glossary/Truthy\">truthy</a>, nothing happens.</p>\n<pre><code class=\"language-js\">console.assert(true, 'does nothing');\n\nconsole.assert(false, 'Whoops %s work', 'didn\\'t');\n// Assertion failed: Whoops didn't work\n\nconsole.assert();\n// Assertion failed\n</code></pre>" 63 }, 64 { 65 "textRaw": "`console.clear()`", 66 "type": "method", 67 "name": "clear", 68 "meta": { 69 "added": [ 70 "v8.3.0" 71 ], 72 "changes": [] 73 }, 74 "signatures": [ 75 { 76 "params": [] 77 } 78 ], 79 "desc": "<p>When <code>stdout</code> is a TTY, calling <code>console.clear()</code> will attempt to clear the\nTTY. When <code>stdout</code> is not a TTY, this method does nothing.</p>\n<p>The specific operation of <code>console.clear()</code> can vary across operating systems\nand terminal types. For most Linux operating systems, <code>console.clear()</code>\noperates similarly to the <code>clear</code> shell command. On Windows, <code>console.clear()</code>\nwill clear only the output in the current terminal viewport for the Node.js\nbinary.</p>" 80 }, 81 { 82 "textRaw": "`console.count([label])`", 83 "type": "method", 84 "name": "count", 85 "meta": { 86 "added": [ 87 "v8.3.0" 88 ], 89 "changes": [] 90 }, 91 "signatures": [ 92 { 93 "params": [ 94 { 95 "textRaw": "`label` {string} The display label for the counter. **Default:** `'default'`.", 96 "name": "label", 97 "type": "string", 98 "default": "`'default'`", 99 "desc": "The display label for the counter." 100 } 101 ] 102 } 103 ], 104 "desc": "<p>Maintains an internal counter specific to <code>label</code> and outputs to <code>stdout</code> the\nnumber of times <code>console.count()</code> has been called with the given <code>label</code>.</p>\n<!-- eslint-skip -->\n<pre><code class=\"language-js\">> console.count()\ndefault: 1\nundefined\n> console.count('default')\ndefault: 2\nundefined\n> console.count('abc')\nabc: 1\nundefined\n> console.count('xyz')\nxyz: 1\nundefined\n> console.count('abc')\nabc: 2\nundefined\n> console.count()\ndefault: 3\nundefined\n>\n</code></pre>" 105 }, 106 { 107 "textRaw": "`console.countReset([label])`", 108 "type": "method", 109 "name": "countReset", 110 "meta": { 111 "added": [ 112 "v8.3.0" 113 ], 114 "changes": [] 115 }, 116 "signatures": [ 117 { 118 "params": [ 119 { 120 "textRaw": "`label` {string} The display label for the counter. **Default:** `'default'`.", 121 "name": "label", 122 "type": "string", 123 "default": "`'default'`", 124 "desc": "The display label for the counter." 125 } 126 ] 127 } 128 ], 129 "desc": "<p>Resets the internal counter specific to <code>label</code>.</p>\n<!-- eslint-skip -->\n<pre><code class=\"language-js\">> console.count('abc');\nabc: 1\nundefined\n> console.countReset('abc');\nundefined\n> console.count('abc');\nabc: 1\nundefined\n>\n</code></pre>" 130 }, 131 { 132 "textRaw": "`console.debug(data[, ...args])`", 133 "type": "method", 134 "name": "debug", 135 "meta": { 136 "added": [ 137 "v8.0.0" 138 ], 139 "changes": [ 140 { 141 "version": "v8.10.0", 142 "pr-url": "https://github.com/nodejs/node/pull/17033", 143 "description": "`console.debug` is now an alias for `console.log`." 144 } 145 ] 146 }, 147 "signatures": [ 148 { 149 "params": [ 150 { 151 "textRaw": "`data` {any}", 152 "name": "data", 153 "type": "any" 154 }, 155 { 156 "textRaw": "`...args` {any}", 157 "name": "...args", 158 "type": "any" 159 } 160 ] 161 } 162 ], 163 "desc": "<p>The <code>console.debug()</code> function is an alias for <a href=\"#console_console_log_data_args\"><code>console.log()</code></a>.</p>" 164 }, 165 { 166 "textRaw": "`console.dir(obj[, options])`", 167 "type": "method", 168 "name": "dir", 169 "meta": { 170 "added": [ 171 "v0.1.101" 172 ], 173 "changes": [] 174 }, 175 "signatures": [ 176 { 177 "params": [ 178 { 179 "textRaw": "`obj` {any}", 180 "name": "obj", 181 "type": "any" 182 }, 183 { 184 "textRaw": "`options` {Object}", 185 "name": "options", 186 "type": "Object", 187 "options": [ 188 { 189 "textRaw": "`showHidden` {boolean} If `true` then the object's non-enumerable and symbol properties will be shown too. **Default:** `false`.", 190 "name": "showHidden", 191 "type": "boolean", 192 "default": "`false`", 193 "desc": "If `true` then the object's non-enumerable and symbol properties will be shown too." 194 }, 195 { 196 "textRaw": "`depth` {number} Tells [`util.inspect()`][] how many times to recurse while formatting the object. This is useful for inspecting large complicated objects. To make it recurse indefinitely, pass `null`. **Default:** `2`.", 197 "name": "depth", 198 "type": "number", 199 "default": "`2`", 200 "desc": "Tells [`util.inspect()`][] how many times to recurse while formatting the object. This is useful for inspecting large complicated objects. To make it recurse indefinitely, pass `null`." 201 }, 202 { 203 "textRaw": "`colors` {boolean} If `true`, then the output will be styled with ANSI color codes. Colors are customizable; see [customizing `util.inspect()` colors][]. **Default:** `false`.", 204 "name": "colors", 205 "type": "boolean", 206 "default": "`false`", 207 "desc": "If `true`, then the output will be styled with ANSI color codes. Colors are customizable; see [customizing `util.inspect()` colors][]." 208 } 209 ] 210 } 211 ] 212 } 213 ], 214 "desc": "<p>Uses <a href=\"util.html#util_util_inspect_object_options\"><code>util.inspect()</code></a> on <code>obj</code> and prints the resulting string to <code>stdout</code>.\nThis function bypasses any custom <code>inspect()</code> function defined on <code>obj</code>.</p>" 215 }, 216 { 217 "textRaw": "`console.dirxml(...data)`", 218 "type": "method", 219 "name": "dirxml", 220 "meta": { 221 "added": [ 222 "v8.0.0" 223 ], 224 "changes": [ 225 { 226 "version": "v9.3.0", 227 "pr-url": "https://github.com/nodejs/node/pull/17152", 228 "description": "`console.dirxml` now calls `console.log` for its arguments." 229 } 230 ] 231 }, 232 "signatures": [ 233 { 234 "params": [ 235 { 236 "textRaw": "`...data` {any}", 237 "name": "...data", 238 "type": "any" 239 } 240 ] 241 } 242 ], 243 "desc": "<p>This method calls <code>console.log()</code> passing it the arguments received.\nThis method does not produce any XML formatting.</p>" 244 }, 245 { 246 "textRaw": "`console.error([data][, ...args])`", 247 "type": "method", 248 "name": "error", 249 "meta": { 250 "added": [ 251 "v0.1.100" 252 ], 253 "changes": [] 254 }, 255 "signatures": [ 256 { 257 "params": [ 258 { 259 "textRaw": "`data` {any}", 260 "name": "data", 261 "type": "any" 262 }, 263 { 264 "textRaw": "`...args` {any}", 265 "name": "...args", 266 "type": "any" 267 } 268 ] 269 } 270 ], 271 "desc": "<p>Prints to <code>stderr</code> with newline. Multiple arguments can be passed, with the\nfirst used as the primary message and all additional used as substitution\nvalues similar to <a href=\"http://man7.org/linux/man-pages/man3/printf.3.html\"><code>printf(3)</code></a> (the arguments are all passed to\n<a href=\"util.html#util_util_format_format_args\"><code>util.format()</code></a>).</p>\n<pre><code class=\"language-js\">const code = 5;\nconsole.error('error #%d', code);\n// Prints: error #5, to stderr\nconsole.error('error', code);\n// Prints: error 5, to stderr\n</code></pre>\n<p>If formatting elements (e.g. <code>%d</code>) are not found in the first string then\n<a href=\"util.html#util_util_inspect_object_options\"><code>util.inspect()</code></a> is called on each argument and the resulting string\nvalues are concatenated. See <a href=\"util.html#util_util_format_format_args\"><code>util.format()</code></a> for more information.</p>" 272 }, 273 { 274 "textRaw": "`console.group([...label])`", 275 "type": "method", 276 "name": "group", 277 "meta": { 278 "added": [ 279 "v8.5.0" 280 ], 281 "changes": [] 282 }, 283 "signatures": [ 284 { 285 "params": [ 286 { 287 "textRaw": "`...label` {any}", 288 "name": "...label", 289 "type": "any" 290 } 291 ] 292 } 293 ], 294 "desc": "<p>Increases indentation of subsequent lines by spaces for <code>groupIndentation</code>\nlength.</p>\n<p>If one or more <code>label</code>s are provided, those are printed first without the\nadditional indentation.</p>" 295 }, 296 { 297 "textRaw": "`console.groupCollapsed()`", 298 "type": "method", 299 "name": "groupCollapsed", 300 "meta": { 301 "added": [ 302 "v8.5.0" 303 ], 304 "changes": [] 305 }, 306 "signatures": [ 307 { 308 "params": [] 309 } 310 ], 311 "desc": "<p>An alias for <a href=\"#console_console_group_label\"><code>console.group()</code></a>.</p>" 312 }, 313 { 314 "textRaw": "`console.groupEnd()`", 315 "type": "method", 316 "name": "groupEnd", 317 "meta": { 318 "added": [ 319 "v8.5.0" 320 ], 321 "changes": [] 322 }, 323 "signatures": [ 324 { 325 "params": [] 326 } 327 ], 328 "desc": "<p>Decreases indentation of subsequent lines by spaces for <code>groupIndentation</code>\nlength.</p>" 329 }, 330 { 331 "textRaw": "`console.info([data][, ...args])`", 332 "type": "method", 333 "name": "info", 334 "meta": { 335 "added": [ 336 "v0.1.100" 337 ], 338 "changes": [] 339 }, 340 "signatures": [ 341 { 342 "params": [ 343 { 344 "textRaw": "`data` {any}", 345 "name": "data", 346 "type": "any" 347 }, 348 { 349 "textRaw": "`...args` {any}", 350 "name": "...args", 351 "type": "any" 352 } 353 ] 354 } 355 ], 356 "desc": "<p>The <code>console.info()</code> function is an alias for <a href=\"#console_console_log_data_args\"><code>console.log()</code></a>.</p>" 357 }, 358 { 359 "textRaw": "`console.log([data][, ...args])`", 360 "type": "method", 361 "name": "log", 362 "meta": { 363 "added": [ 364 "v0.1.100" 365 ], 366 "changes": [] 367 }, 368 "signatures": [ 369 { 370 "params": [ 371 { 372 "textRaw": "`data` {any}", 373 "name": "data", 374 "type": "any" 375 }, 376 { 377 "textRaw": "`...args` {any}", 378 "name": "...args", 379 "type": "any" 380 } 381 ] 382 } 383 ], 384 "desc": "<p>Prints to <code>stdout</code> with newline. Multiple arguments can be passed, with the\nfirst used as the primary message and all additional used as substitution\nvalues similar to <a href=\"http://man7.org/linux/man-pages/man3/printf.3.html\"><code>printf(3)</code></a> (the arguments are all passed to\n<a href=\"util.html#util_util_format_format_args\"><code>util.format()</code></a>).</p>\n<pre><code class=\"language-js\">const count = 5;\nconsole.log('count: %d', count);\n// Prints: count: 5, to stdout\nconsole.log('count:', count);\n// Prints: count: 5, to stdout\n</code></pre>\n<p>See <a href=\"util.html#util_util_format_format_args\"><code>util.format()</code></a> for more information.</p>" 385 }, 386 { 387 "textRaw": "`console.table(tabularData[, properties])`", 388 "type": "method", 389 "name": "table", 390 "meta": { 391 "added": [ 392 "v10.0.0" 393 ], 394 "changes": [] 395 }, 396 "signatures": [ 397 { 398 "params": [ 399 { 400 "textRaw": "`tabularData` {any}", 401 "name": "tabularData", 402 "type": "any" 403 }, 404 { 405 "textRaw": "`properties` {string[]} Alternate properties for constructing the table.", 406 "name": "properties", 407 "type": "string[]", 408 "desc": "Alternate properties for constructing the table." 409 } 410 ] 411 } 412 ], 413 "desc": "<p>Try to construct a table with the columns of the properties of <code>tabularData</code>\n(or use <code>properties</code>) and rows of <code>tabularData</code> and log it. Falls back to just\nlogging the argument if it can’t be parsed as tabular.</p>\n<pre><code class=\"language-js\">// These can't be parsed as tabular data\nconsole.table(Symbol());\n// Symbol()\n\nconsole.table(undefined);\n// undefined\n\nconsole.table([{ a: 1, b: 'Y' }, { a: 'Z', b: 2 }]);\n// ┌─────────┬─────┬─────┐\n// │ (index) │ a │ b │\n// ├─────────┼─────┼─────┤\n// │ 0 │ 1 │ 'Y' │\n// │ 1 │ 'Z' │ 2 │\n// └─────────┴─────┴─────┘\n\nconsole.table([{ a: 1, b: 'Y' }, { a: 'Z', b: 2 }], ['a']);\n// ┌─────────┬─────┐\n// │ (index) │ a │\n// ├─────────┼─────┤\n// │ 0 │ 1 │\n// │ 1 │ 'Z' │\n// └─────────┴─────┘\n</code></pre>" 414 }, 415 { 416 "textRaw": "`console.time([label])`", 417 "type": "method", 418 "name": "time", 419 "meta": { 420 "added": [ 421 "v0.1.104" 422 ], 423 "changes": [] 424 }, 425 "signatures": [ 426 { 427 "params": [ 428 { 429 "textRaw": "`label` {string} **Default:** `'default'`", 430 "name": "label", 431 "type": "string", 432 "default": "`'default'`" 433 } 434 ] 435 } 436 ], 437 "desc": "<p>Starts a timer that can be used to compute the duration of an operation. Timers\nare identified by a unique <code>label</code>. Use the same <code>label</code> when calling\n<a href=\"#console_console_timeend_label\"><code>console.timeEnd()</code></a> to stop the timer and output the elapsed time in\nsuitable time units to <code>stdout</code>. For example, if the elapsed\ntime is 3869ms, <code>console.timeEnd()</code> displays \"3.869s\".</p>" 438 }, 439 { 440 "textRaw": "`console.timeEnd([label])`", 441 "type": "method", 442 "name": "timeEnd", 443 "meta": { 444 "added": [ 445 "v0.1.104" 446 ], 447 "changes": [ 448 { 449 "version": "v13.0.0", 450 "pr-url": "https://github.com/nodejs/node/pull/29251", 451 "description": "The elapsed time is displayed with a suitable time unit." 452 }, 453 { 454 "version": "v6.0.0", 455 "pr-url": "https://github.com/nodejs/node/pull/5901", 456 "description": "This method no longer supports multiple calls that don’t map to individual `console.time()` calls; see below for details." 457 } 458 ] 459 }, 460 "signatures": [ 461 { 462 "params": [ 463 { 464 "textRaw": "`label` {string} **Default:** `'default'`", 465 "name": "label", 466 "type": "string", 467 "default": "`'default'`" 468 } 469 ] 470 } 471 ], 472 "desc": "<p>Stops a timer that was previously started by calling <a href=\"#console_console_time_label\"><code>console.time()</code></a> and\nprints the result to <code>stdout</code>:</p>\n<pre><code class=\"language-js\">console.time('100-elements');\nfor (let i = 0; i < 100; i++) {}\nconsole.timeEnd('100-elements');\n// prints 100-elements: 225.438ms\n</code></pre>" 473 }, 474 { 475 "textRaw": "`console.timeLog([label][, ...data])`", 476 "type": "method", 477 "name": "timeLog", 478 "meta": { 479 "added": [ 480 "v10.7.0" 481 ], 482 "changes": [] 483 }, 484 "signatures": [ 485 { 486 "params": [ 487 { 488 "textRaw": "`label` {string} **Default:** `'default'`", 489 "name": "label", 490 "type": "string", 491 "default": "`'default'`" 492 }, 493 { 494 "textRaw": "`...data` {any}", 495 "name": "...data", 496 "type": "any" 497 } 498 ] 499 } 500 ], 501 "desc": "<p>For a timer that was previously started by calling <a href=\"#console_console_time_label\"><code>console.time()</code></a>, prints\nthe elapsed time and other <code>data</code> arguments to <code>stdout</code>:</p>\n<pre><code class=\"language-js\">console.time('process');\nconst value = expensiveProcess1(); // Returns 42\nconsole.timeLog('process', value);\n// Prints \"process: 365.227ms 42\".\ndoExpensiveProcess2(value);\nconsole.timeEnd('process');\n</code></pre>" 502 }, 503 { 504 "textRaw": "`console.trace([message][, ...args])`", 505 "type": "method", 506 "name": "trace", 507 "meta": { 508 "added": [ 509 "v0.1.104" 510 ], 511 "changes": [] 512 }, 513 "signatures": [ 514 { 515 "params": [ 516 { 517 "textRaw": "`message` {any}", 518 "name": "message", 519 "type": "any" 520 }, 521 { 522 "textRaw": "`...args` {any}", 523 "name": "...args", 524 "type": "any" 525 } 526 ] 527 } 528 ], 529 "desc": "<p>Prints to <code>stderr</code> the string <code>'Trace: '</code>, followed by the <a href=\"util.html#util_util_format_format_args\"><code>util.format()</code></a>\nformatted message and stack trace to the current position in the code.</p>\n<pre><code class=\"language-js\">console.trace('Show me');\n// Prints: (stack trace will vary based on where trace is called)\n// Trace: Show me\n// at repl:2:9\n// at REPLServer.defaultEval (repl.js:248:27)\n// at bound (domain.js:287:14)\n// at REPLServer.runBound [as eval] (domain.js:300:12)\n// at REPLServer.<anonymous> (repl.js:412:12)\n// at emitOne (events.js:82:20)\n// at REPLServer.emit (events.js:169:7)\n// at REPLServer.Interface._onLine (readline.js:210:10)\n// at REPLServer.Interface._line (readline.js:549:8)\n// at REPLServer.Interface._ttyWrite (readline.js:826:14)\n</code></pre>" 530 }, 531 { 532 "textRaw": "`console.warn([data][, ...args])`", 533 "type": "method", 534 "name": "warn", 535 "meta": { 536 "added": [ 537 "v0.1.100" 538 ], 539 "changes": [] 540 }, 541 "signatures": [ 542 { 543 "params": [ 544 { 545 "textRaw": "`data` {any}", 546 "name": "data", 547 "type": "any" 548 }, 549 { 550 "textRaw": "`...args` {any}", 551 "name": "...args", 552 "type": "any" 553 } 554 ] 555 } 556 ], 557 "desc": "<p>The <code>console.warn()</code> function is an alias for <a href=\"#console_console_error_data_args\"><code>console.error()</code></a>.</p>" 558 } 559 ], 560 "signatures": [ 561 { 562 "params": [ 563 { 564 "textRaw": "`options` {Object}", 565 "name": "options", 566 "type": "Object", 567 "options": [ 568 { 569 "textRaw": "`stdout` {stream.Writable}", 570 "name": "stdout", 571 "type": "stream.Writable" 572 }, 573 { 574 "textRaw": "`stderr` {stream.Writable}", 575 "name": "stderr", 576 "type": "stream.Writable" 577 }, 578 { 579 "textRaw": "`ignoreErrors` {boolean} Ignore errors when writing to the underlying streams. **Default:** `true`.", 580 "name": "ignoreErrors", 581 "type": "boolean", 582 "default": "`true`", 583 "desc": "Ignore errors when writing to the underlying streams." 584 }, 585 { 586 "textRaw": "`colorMode` {boolean|string} Set color support for this `Console` instance. Setting to `true` enables coloring while inspecting values. Setting to `false` disables coloring while inspecting values. Setting to `'auto'` makes color support depend on the value of the `isTTY` property and the value returned by `getColorDepth()` on the respective stream. This option can not be used, if `inspectOptions.colors` is set as well. **Default:** `'auto'`.", 587 "name": "colorMode", 588 "type": "boolean|string", 589 "default": "`'auto'`", 590 "desc": "Set color support for this `Console` instance. Setting to `true` enables coloring while inspecting values. Setting to `false` disables coloring while inspecting values. Setting to `'auto'` makes color support depend on the value of the `isTTY` property and the value returned by `getColorDepth()` on the respective stream. This option can not be used, if `inspectOptions.colors` is set as well." 591 }, 592 { 593 "textRaw": "`inspectOptions` {Object} Specifies options that are passed along to [`util.inspect()`][].", 594 "name": "inspectOptions", 595 "type": "Object", 596 "desc": "Specifies options that are passed along to [`util.inspect()`][]." 597 }, 598 { 599 "textRaw": "`groupIndentation` {number} Set group indentation. **Default:** `2`.", 600 "name": "groupIndentation", 601 "type": "number", 602 "default": "`2`", 603 "desc": "Set group indentation." 604 } 605 ] 606 } 607 ], 608 "desc": "<p>Creates a new <code>Console</code> with one or two writable stream instances. <code>stdout</code> is a\nwritable stream to print log or info output. <code>stderr</code> is used for warning or\nerror output. If <code>stderr</code> is not provided, <code>stdout</code> is used for <code>stderr</code>.</p>\n<pre><code class=\"language-js\">const output = fs.createWriteStream('./stdout.log');\nconst errorOutput = fs.createWriteStream('./stderr.log');\n// Custom simple logger\nconst logger = new Console({ stdout: output, stderr: errorOutput });\n// use it like console\nconst count = 5;\nlogger.log('count: %d', count);\n// In stdout.log: count 5\n</code></pre>\n<p>The global <code>console</code> is a special <code>Console</code> whose output is sent to\n<a href=\"process.html#process_process_stdout\"><code>process.stdout</code></a> and <a href=\"process.html#process_process_stderr\"><code>process.stderr</code></a>. It is equivalent to calling:</p>\n<pre><code class=\"language-js\">new Console({ stdout: process.stdout, stderr: process.stderr });\n</code></pre>" 609 }, 610 { 611 "params": [ 612 { 613 "textRaw": "`options` {Object}", 614 "name": "options", 615 "type": "Object", 616 "options": [ 617 { 618 "textRaw": "`stdout` {stream.Writable}", 619 "name": "stdout", 620 "type": "stream.Writable" 621 }, 622 { 623 "textRaw": "`stderr` {stream.Writable}", 624 "name": "stderr", 625 "type": "stream.Writable" 626 }, 627 { 628 "textRaw": "`ignoreErrors` {boolean} Ignore errors when writing to the underlying streams. **Default:** `true`.", 629 "name": "ignoreErrors", 630 "type": "boolean", 631 "default": "`true`", 632 "desc": "Ignore errors when writing to the underlying streams." 633 }, 634 { 635 "textRaw": "`colorMode` {boolean|string} Set color support for this `Console` instance. Setting to `true` enables coloring while inspecting values. Setting to `false` disables coloring while inspecting values. Setting to `'auto'` makes color support depend on the value of the `isTTY` property and the value returned by `getColorDepth()` on the respective stream. This option can not be used, if `inspectOptions.colors` is set as well. **Default:** `'auto'`.", 636 "name": "colorMode", 637 "type": "boolean|string", 638 "default": "`'auto'`", 639 "desc": "Set color support for this `Console` instance. Setting to `true` enables coloring while inspecting values. Setting to `false` disables coloring while inspecting values. Setting to `'auto'` makes color support depend on the value of the `isTTY` property and the value returned by `getColorDepth()` on the respective stream. This option can not be used, if `inspectOptions.colors` is set as well." 640 }, 641 { 642 "textRaw": "`inspectOptions` {Object} Specifies options that are passed along to [`util.inspect()`][].", 643 "name": "inspectOptions", 644 "type": "Object", 645 "desc": "Specifies options that are passed along to [`util.inspect()`][]." 646 }, 647 { 648 "textRaw": "`groupIndentation` {number} Set group indentation. **Default:** `2`.", 649 "name": "groupIndentation", 650 "type": "number", 651 "default": "`2`", 652 "desc": "Set group indentation." 653 } 654 ] 655 } 656 ], 657 "desc": "<p>Creates a new <code>Console</code> with one or two writable stream instances. <code>stdout</code> is a\nwritable stream to print log or info output. <code>stderr</code> is used for warning or\nerror output. If <code>stderr</code> is not provided, <code>stdout</code> is used for <code>stderr</code>.</p>\n<pre><code class=\"language-js\">const output = fs.createWriteStream('./stdout.log');\nconst errorOutput = fs.createWriteStream('./stderr.log');\n// Custom simple logger\nconst logger = new Console({ stdout: output, stderr: errorOutput });\n// use it like console\nconst count = 5;\nlogger.log('count: %d', count);\n// In stdout.log: count 5\n</code></pre>\n<p>The global <code>console</code> is a special <code>Console</code> whose output is sent to\n<a href=\"process.html#process_process_stdout\"><code>process.stdout</code></a> and <a href=\"process.html#process_process_stderr\"><code>process.stderr</code></a>. It is equivalent to calling:</p>\n<pre><code class=\"language-js\">new Console({ stdout: process.stdout, stderr: process.stderr });\n</code></pre>" 658 } 659 ] 660 } 661 ], 662 "modules": [ 663 { 664 "textRaw": "Inspector only methods", 665 "name": "inspector_only_methods", 666 "desc": "<p>The following methods are exposed by the V8 engine in the general API but do\nnot display anything unless used in conjunction with the <a href=\"debugger.html\">inspector</a>\n(<code>--inspect</code> flag).</p>", 667 "methods": [ 668 { 669 "textRaw": "`console.profile([label])`", 670 "type": "method", 671 "name": "profile", 672 "meta": { 673 "added": [ 674 "v8.0.0" 675 ], 676 "changes": [] 677 }, 678 "signatures": [ 679 { 680 "params": [ 681 { 682 "textRaw": "`label` {string}", 683 "name": "label", 684 "type": "string" 685 } 686 ] 687 } 688 ], 689 "desc": "<p>This method does not display anything unless used in the inspector. The\n<code>console.profile()</code> method starts a JavaScript CPU profile with an optional\nlabel until <a href=\"#console_console_profileend_label\"><code>console.profileEnd()</code></a> is called. The profile is then added to\nthe <strong>Profile</strong> panel of the inspector.</p>\n<pre><code class=\"language-js\">console.profile('MyLabel');\n// Some code\nconsole.profileEnd('MyLabel');\n// Adds the profile 'MyLabel' to the Profiles panel of the inspector.\n</code></pre>" 690 }, 691 { 692 "textRaw": "`console.profileEnd([label])`", 693 "type": "method", 694 "name": "profileEnd", 695 "meta": { 696 "added": [ 697 "v8.0.0" 698 ], 699 "changes": [] 700 }, 701 "signatures": [ 702 { 703 "params": [ 704 { 705 "textRaw": "`label` {string}", 706 "name": "label", 707 "type": "string" 708 } 709 ] 710 } 711 ], 712 "desc": "<p>This method does not display anything unless used in the inspector. Stops the\ncurrent JavaScript CPU profiling session if one has been started and prints\nthe report to the <strong>Profiles</strong> panel of the inspector. See\n<a href=\"#console_console_profile_label\"><code>console.profile()</code></a> for an example.</p>\n<p>If this method is called without a label, the most recently started profile is\nstopped.</p>" 713 }, 714 { 715 "textRaw": "`console.timeStamp([label])`", 716 "type": "method", 717 "name": "timeStamp", 718 "meta": { 719 "added": [ 720 "v8.0.0" 721 ], 722 "changes": [] 723 }, 724 "signatures": [ 725 { 726 "params": [ 727 { 728 "textRaw": "`label` {string}", 729 "name": "label", 730 "type": "string" 731 } 732 ] 733 } 734 ], 735 "desc": "<p>This method does not display anything unless used in the inspector. The\n<code>console.timeStamp()</code> method adds an event with the label <code>'label'</code> to the\n<strong>Timeline</strong> panel of the inspector.</p>" 736 } 737 ], 738 "type": "module", 739 "displayName": "Inspector only methods" 740 } 741 ], 742 "type": "module", 743 "displayName": "Console" 744 } 745 ] 746}