class Console extends Object
The console module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers.
The module exports two specific components:
- A
Console
class with methods such asconsole.log()
,console.error()
andconsole.warn()
that can be used to write to any Node.js stream. - A global
console
instance configured to write toprocess.stdout
andprocess.stderr
. The globalconsole
can be used without callingrequire('console')
.
Warning: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the note on process I/O for more information.
- Annotations
- @JSType() @native() @JSImport("console", "Console")
- See also
https://nodejs.org/api/console.html
- Alphabetic
- By Inheritance
- Console
- Object
- Any
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Instance Constructors
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def assert(value: Any, optionalParams: Any*): Unit
A simple assertion test that verifies whether
value
is truthy.A simple assertion test that verifies whether
value
is truthy. If it is not, anAssertionError
is thrown. If provided, the errormessage
is formatted usingutil.format()
and used as the error message.- value
The value tested for being truthy
- optionalParams
The arguments passed to the error message
- def assert(value: Any, message: String, optionalParams: Any*): Unit
A simple assertion test that verifies whether
value
is truthy.A simple assertion test that verifies whether
value
is truthy. If it is not, anAssertionError
is thrown. If provided, the errormessage
is formatted usingutil.format()
and used as the error message.- value
The value tested for being truthy
- message
The error message
- optionalParams
The arguments passed to
message
- def clear(): Unit
When
stdout
is a TTY, callingconsole.clear()
will attempt to clear the TTY.When
stdout
is a TTY, callingconsole.clear()
will attempt to clear the TTY. Whenstdout
is not a TTY, this method does nothing.The specific operation of
console.clear()
can vary across operating systems and terminal types. For most Linux operating systems,console.clear()
operates similarly to the clear shell command. On Windows,console.clear()
will clear only the output in the current terminal viewport for the Node.js binary. - def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
- def count(): Unit
- def count(label: String): Unit
Maintains an internal counter specific to
label
and outputs tostdout
the number of timesconsole.count()
has been called with the givenlabel
.Maintains an internal counter specific to
label
and outputs tostdout
the number of timesconsole.count()
has been called with the givenlabel
.- label
The display label for the counter. Default: 'default'.
- def countReset(): Unit
- def countReset(label: String): Unit
Resets the internal counter specific to
label
.Resets the internal counter specific to
label
.- label
The display label for the counter. Default: 'default'.
- def debug(): Unit
- def debug(data: Any): Unit
- def debug(data: Any, arg1: Any, args: Any*): Unit
The
console.debug()
function is an alias forconsole.log()
. - def dir(obj: Any): Unit
- def dir(obj: Any, options: ConsoleDirOptions): Unit
Uses io.scalajs.nodejs.util.Util.inspect() on
obj
and prints the resulting string tostdout
.Uses io.scalajs.nodejs.util.Util.inspect() on
obj
and prints the resulting string tostdout
. This function bypasses any custominspect()
function defined onobj
. - def dirxml(data: Any*): Unit
This method callslog() passing it the arguments received.
This method callslog() passing it the arguments received. Please note that this method does not produce any XML formatting
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def error(): Unit
- def error(data: Any): Unit
- def error(data: Any, arg1: Any, args: Any*): Unit
Prints to
stderr
with newline.Prints to
stderr
with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar toprintf(3)
(the arguments are all passed to io.scalajs.nodejs.util.Util.format().If formatting elements (e.g.
%d
) are not found in the first string thenio.scalajs.nodejs.util.Util.inspect() is called on each argument and the resulting string values are concatenated. See io.scalajs.nodejs.util.Util.format() for more information. - def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def group(label: Any*): Unit
Increases indentation of subsequent lines by two spaces.
Increases indentation of subsequent lines by two spaces.
If one or more
label
s are provided, those are printed first without the additional indentation. - def groupCollapsed(label: Any*): Unit
An alias for group()
- def groupEnd(): Unit
Decreases indentation of subsequent lines by two spaces.
- def hasOwnProperty(v: String): Boolean
- Definition Classes
- Object
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def info(): Unit
- def info(data: Any): Unit
- def info(data: Any, arg1: Any, args: Any*): Unit
The
console.info()
function is an alias for log(). - final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def isPrototypeOf(v: Object): Boolean
- Definition Classes
- Object
- def log(): Unit
- def log(data: Any): Unit
- def log(data: Any, arg1: Any, args: Any*): Unit
Prints to
stdout
with newline.Prints to
stdout
with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar toprintf(3)
(the arguments are all passed toutil.format()
). - final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- def profile(): Unit
- def profile(label: String): Unit
This method does not display anything unless used in the inspector.
This method does not display anything unless used in the inspector. The
console.profile()
method starts a JavaScript CPU profile with an optional label until profileEnd() is called. The profile is then added to the **Profile** panel of the inspector. - def profileEnd(): Unit
- def profileEnd(label: String): Unit
This method does not display anything unless used in the inspector.
This method does not display anything unless used in the inspector. Stops the current JavaScript CPU profiling session if one has been started and prints the report to the **Profiles** panel of the inspector. See profile() for an example.
If this method is called without a label, the most recently started profile is stopped.
- def propertyIsEnumerable(v: String): Boolean
- Definition Classes
- Object
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def table(tabularData: Any): Unit
- def table(tabularData: Any, properties: Array[String]): Unit
Try to construct a table with the columns of the properties of
tabularData
(or useproperties
) and rows oftabularData
and log it.Try to construct a table with the columns of the properties of
tabularData
(or useproperties
) and rows oftabularData
and log it. Falls back to just logging the argument if it can’t be parsed as tabular.- properties
Alternate properties for constructing the table.
- def time(): Unit
- def time(label: String): Unit
Starts a timer that can be used to compute the duration of an operation.
Starts a timer that can be used to compute the duration of an operation. Timers are identified by a unique
label
. Use the samelabel
when calling timeEnd() to stop the timer and output the elapsed time in milliseconds tostdout
. Timer durations are accurate to the sub-millisecond. - def timeEnd(): Unit
- def timeEnd(label: String): Unit
Stops a timer that was previously started by calling time() and prints the result to
stdout
. - def timeLog(label: String, data: Any*): Unit
Stops a timer that was previously started by calling time() and prints the result to
.stdout
. - def timeStamp(): Unit
- def timeStamp(label: String): Unit
This method does not display anything unless used in the inspector.
This method does not display anything unless used in the inspector. The
console.timeStamp()
method adds an event with the label'label'
to the **Timeline** panel of the inspector. - def toLocaleString(): String
- Definition Classes
- Object
- def toString(): String
- Definition Classes
- AnyRef → Any
- def trace(): Unit
- def trace(data: Any): Unit
- def trace(data: Any, arg1: Any, args: Any*): Unit
Prints to
stderr
the string'Trace: '
, followed by the io.scalajs.nodejs.util.Util.format() formatted message and stack trace to the current position in the code. - def valueOf(): Any
- Definition Classes
- Object
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- def warn(): Unit
- def warn(data: Any): Unit
- def warn(data: Any, arg1: Any, args: Any*): Unit
The
console.warn()
function is an alias for