The Console class can be used to create a simple logger with configurable output streams and can be accessed using either require('console').Console or console.Console (or their destructured counterparts):

See also:

Constructor

new(stdout:IWritable, ?stderr:IWritable, ?ignoreerrors:Bool)

new(options:ConsoleOptions)

Creates a new Console with one or two writable stream instances. stdout is a writable stream to print log or info output. stderr is used for warning or error output. If stderr is not provided, stdout is used for stderr.

See also:

Methods

assert(value:Dynamic, message:Rest<Dynamic>):Void

A simple assertion test that verifies whether value is truthy. If it is not, Assertion failed is logged. If provided, the error message is formatted using util.format() by passing along all message arguments. The output is used as the error message.

See also:

clear():Void

When stdout is a TTY, calling console.clear() will attempt to clear the TTY. When stdout is not a TTY, this method does nothing.

See also:

count(?label:String):Void

Maintains an internal counter specific to label and outputs to stdout the number of times console.count() has been called with the given label.

See also:

countReset(?label:String):Void

Resets the internal counter specific to label.

See also:

debug(data:Dynamic, args:Rest<Dynamic>):Void

The console.debug() function is an alias for console.log().

See also:

dir(obj:Dynamic, ?options:Null<InspectOptionsBase>):Void

Uses util.inspect() on obj and prints the resulting string to stdout. This function bypasses any custom inspect() function defined on obj.

See also:

dirxml(data:Rest<Dynamic>):Void

This method calls console.log() passing it the arguments received. This method does not produce any XML formatting.

See also:

error(data:Dynamic, args:Rest<Dynamic>):Void

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 to printf(3) (the arguments are all passed to util.format()).

See also:

group(label:Rest<Dynamic>):Void

If one or more labels are provided, those are printed first without the additional indentation.

See also:

groupEnd():Void

Decreases indentation of subsequent lines by two spaces.

See also:

info(data:Dynamic, args:Rest<Dynamic>):Void

The console.info() function is an alias for console.log().

See also:

log(data:Dynamic, args:Rest<Dynamic>):Void

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 to printf(3) (the arguments are all passed to util.format()).

See also:

markTimeline(?label:String):Void

This method does not display anything unless used in the inspector. The console.markTimeline() method is the deprecated form of console.timeStamp().

See also:

profile(?label:String):Void

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 console.profileEnd() is called. The profile is then added to the Profile panel of the inspector.

See also:

profileEnd(?label:String):Void

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 console.profile() for an example.

See also:

table(tabularData:Dynamic, ?properties:Array<String>):Void

Try to construct a table with the columns of the properties of tabularData (or use properties) and rows of tabularData and log it. Falls back to just logging the argument if it can’t be parsed as tabular.

See also:

time(?label:String):Void

Starts a timer that can be used to compute the duration of an operation. Timers are identified by a unique label. Use the same label when calling console.timeEnd() to stop the timer and output the elapsed time in milliseconds to stdout. Timer durations are accurate to the sub-millisecond.

See also:

timeEnd(?label:String):Void

Stops a timer that was previously started by calling console.time() and prints the result to stdout:

See also:

timeLog(?label:String, data:Rest<Dynamic>):Void

For a timer that was previously started by calling console.time(), prints the elapsed time and other data arguments to stdout:

See also:

timeStamp(?label:String):Void

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.

See also:

timeline(?label:String):Void

This method does not display anything unless used in the inspector. The console.timeline() method is the deprecated form of console.time().

See also:

timelineEnd(?label:String):Void

This method does not display anything unless used in the inspector. The console.timelineEnd() method is the deprecated form of console.timeEnd().

See also:

trace(message:Dynamic, args:Rest<Dynamic>):Void

Prints to stderr the string 'Trace: ', followed by the util.format() formatted message and stack trace to the current position in the code.

See also:

warn(data:Dynamic, args:Rest<Dynamic>):Void

The console.warn() function is an alias for console.error().

See also: