Skip to content

Commit 74c1074

Browse files
TirielMylesBorins
authored andcommitted
doc: add description for inspector-only console methods.
Description inspired by dev tools reference and inspector err messages Added: * intro * console.debug() * console.dirxml() * console.markTimeline() * console.profile() * console.profileEnd() * console.table() * console.timeStamp() * console.timeline() * console.timelineEnd() PR-URL: #17004 Fixes: #16755 Reviewed-By: Khaidi Chu <[email protected]> Reviewed-By: Vse Mozhet Byt <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
1 parent 6922231 commit 74c1074

File tree

1 file changed

+99
-0
lines changed

1 file changed

+99
-0
lines changed

doc/api/console.md

+99
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,10 @@ undefined
240240
### console.debug(data[, ...args])
241241
<!-- YAML
242242
added: v8.0.0
243+
changes:
244+
- version: REPLACEME
245+
pr-url: https://github.com/nodejs/node/pull/17033
246+
description: "`console.debug` is now an alias for `console.log`."
243247
-->
244248
* `data` {any}
245249
* `...args` {any}
@@ -417,15 +421,110 @@ added: v0.1.100
417421

418422
The `console.warn()` function is an alias for [`console.error()`][].
419423

424+
## Inspector only methods
425+
The following methods are exposed by the V8 engine in the general API but do
426+
not display anything unless used in conjunction with the [inspector][]
427+
(`--inspect` flag).
428+
429+
### console.dirxml(object)
430+
<!-- YAML
431+
added: v8.0.0
432+
-->
433+
* `object` {string}
434+
435+
This method does not display anything unless used in the inspector. The
436+
`console.dirxml()` method displays in `stdout` an XML interactive tree
437+
representation of the descendants of the specified `object` if possible, or the
438+
JavaScript representation if not. Calling `console.dirxml()` on an HTML or XML
439+
element is equivalent to calling `console.log()`.
440+
441+
### console.markTimeline(label)
442+
<!-- YAML
443+
added: v8.0.0
444+
-->
445+
* `label` {string} Defaults to `'default'`.
446+
447+
This method does not display anything unless used in the inspector. The
448+
`console.markTimeline()` method is the deprecated form of [`console.timeStamp()`][].
449+
450+
### console.profile([label])
451+
<!-- YAML
452+
added: v8.0.0
453+
-->
454+
* `label` {string}
455+
456+
This method does not display anything unless used in the inspector. The
457+
`console.profile()` method starts a JavaScript CPU profile with an optional
458+
label until [`console.profileEnd()`][] is called. The profile is then added to
459+
the **Profile** panel of the inspector.
460+
```js
461+
console.profile('MyLabel');
462+
// Some code
463+
console.profileEnd();
464+
// Adds the profile 'MyLabel' to the Profiles panel of the inspector.
465+
```
466+
467+
### console.profileEnd()
468+
<!-- YAML
469+
added: v8.0.0
470+
-->
471+
472+
This method does not display anything unless used in the inspector. Stops the
473+
current JavaScript CPU profiling session if one has been started and prints
474+
the report to the **Profiles** panel of the inspector. See
475+
[`console.profile()`][] for an example.
476+
477+
### console.table(array[, columns])
478+
<!-- YAML
479+
added: v8.0.0
480+
-->
481+
* `array` {Array|Object}
482+
* `columns` {Array}
483+
484+
This method does not display anything unless used in the inspector. Prints to
485+
`stdout` the array `array` formatted as a table.
486+
487+
### console.timeStamp([label])
488+
<!-- YAML
489+
added: v8.0.0
490+
-->
491+
* `label` {string}
492+
493+
This method does not display anything unless used in the inspector. The
494+
`console.timeStamp()` method adds an event with the label `label` to the
495+
**Timeline** panel of the inspector.
496+
497+
### console.timeline([label])
498+
<!-- YAML
499+
added: v8.0.0
500+
-->
501+
* `label` {string} Defaults to `'default'`.
502+
503+
This method does not display anything unless used in the inspector. The
504+
`console.timeline()` method is the deprecated form of [`console.time()`][].
505+
506+
### console.timelineEnd([label])
507+
<!-- YAML
508+
added: v8.0.0
509+
-->
510+
* `label` {string} Defaults to `'default'`.
511+
512+
This method does not display anything unless used in the inspector. The
513+
`console.timelineEnd()` method is the deprecated form of [`console.timeEnd()`][].
514+
420515
[`console.error()`]: #console_console_error_data_args
421516
[`console.group()`]: #console_console_group_label
422517
[`console.log()`]: #console_console_log_data_args
518+
[`console.profile()`]: #console_console_profile_label
519+
[`console.profileEnd()`]: #console_console_profileend
423520
[`console.time()`]: #console_console_time_label
424521
[`console.timeEnd()`]: #console_console_timeend_label
522+
[`console.timeStamp()`]: #console_console_timestamp_label
425523
[`process.stderr`]: process.html#process_process_stderr
426524
[`process.stdout`]: process.html#process_process_stdout
427525
[`util.format()`]: util.html#util_util_format_format_args
428526
[`util.inspect()`]: util.html#util_util_inspect_object_options
429527
[customizing `util.inspect()` colors]: util.html#util_customizing_util_inspect_colors
528+
[inspector]: debugger.html
430529
[note on process I/O]: process.html#process_a_note_on_process_i_o
431530
[web-api-assert]: https://developer.mozilla.org/en-US/docs/Web/API/console/assert

0 commit comments

Comments
 (0)