Skip to content

Commit 74506f7

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 57ee0dd commit 74506f7

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
@@ -241,6 +241,10 @@ undefined
241241
### console.debug(data[, ...args])
242242
<!-- YAML
243243
added: v8.0.0
244+
changes:
245+
- version: REPLACEME
246+
pr-url: https://github.com/nodejs/node/pull/17033
247+
description: "`console.debug` is now an alias for `console.log`."
244248
-->
245249
* `data` {any}
246250
* `...args` {any}
@@ -426,15 +430,110 @@ added: v0.1.100
426430

427431
The `console.warn()` function is an alias for [`console.error()`][].
428432

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

0 commit comments

Comments
 (0)