Skip to content

Commit

Permalink
Provide console API in shell.
Browse files Browse the repository at this point in the history
This supports the "console" API. This is defined as part of the "Global"
object, which means that it will be available by default in the shell
and in any embedding that uses "Globals" to initialize its environment.

Embedders who wish "console" to appear, but who are not using the
"Global" object may still use the NativeConsole class directly if they
want to support "console" in their code.
  • Loading branch information
MaxisTekfield authored and gbrail committed Apr 1, 2022
1 parent 70cb6aa commit b05aa96
Show file tree
Hide file tree
Showing 5 changed files with 903 additions and 0 deletions.
28 changes: 28 additions & 0 deletions man/rhino.1
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,34 @@ Quit shell. The shell will also quit in interactive mode if an end-of-file chara
Get or set JavaScript version number. If no argument is supplied, the current version number is returned. If an argument is supplied, it is expected to be one of 100, 110, 120, 130, 150, 160, 170, 180 or 200 to indicate JavaScript version 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8 or ECMAScript 6 respectively.
.IP write(\fI[expr\&.\&.\&.]\fP)
Evaluate and print expressions like in "print", but without the trailing newline.
.IP console
The console object provides a simple debugging console similar to the console object provided by web browsers.
.RS
.IP console.log(\fIformat[arg,\&.\&.\&.]\fP)
For general output of logging information. String substitution and additional arguments are supported. Prints formatted text according to the format and args supplied with "INFO" prefix. This function is identical to console.info(\fIformat\fP[arg,\&.\&.\&.]).
.IP console.trace(\fIformat[arg,\&.\&.\&.]\fP)
This function is identical to console.log(\fIformat\fP[arg,\&.\&.\&.]) except it prints "TRACE" prefix instead of "INFO".
.IP console.debug(\fIformat[arg,\&.\&.\&.]\fP)
This function is identical to console.log(\fIformat\fP[arg,\&.\&.\&.]) except it prints "DEBUG" prefix instead of "INFO".
.IP console.info(\fIformat[arg,\&.\&.\&.]\fP)
This function is identical to console.log(\fIformat\fP[arg,\&.\&.\&.]).
.IP console.warn(\fIformat[arg,\&.\&.\&.]\fP)
This function is identical to console.log(\fIformat\fP[arg,\&.\&.\&.]) except it prints "WARN" prefix instead of "INFO".
.IP console.error(\fIformat[arg,\&.\&.\&.]\fP)
This function is identical to console.log(\fIformat\fP[arg,\&.\&.\&.]) except it prints "ERROR" prefix instead of "INFO".
.IP console.assert(\fIexpression[arg,\&.\&.\&.]\fP)
Prints error if expression is false. If args are supplied, they will be printed also.
.IP console.count(\fI[label]\fP)
Increases the counter of label by one which starts from zero and prints the label and value after increment. If label is not supplied, "default" is the label.
.IP console.countReset(\fI[label]\fP)
Resets the counter of label to zero. If label is not supplied, "default" is the label.
.IP console.time(\fI[label]\fP)
Starts a timer of label. Use console.timeEnd(\fI[label]\fP) to stop the timer and print the elapsed time. Use console.timeLog(\fI[label]\fP) to print the elapsed time without stopping the timer.
.IP console.timeLog(\fI[label]\fP)
See console.time(\fI[label]\fP).
.IP console.timeEnd(\fI[label]\fP)
See console.time(\fI[label]\fP).
.RE

.SH SEE ALSO
The archived online documentation under
Expand Down
Loading

0 comments on commit b05aa96

Please sign in to comment.