Console
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):
Instance Members
assert(value: Dynamic, message: haxe.extern.Rest): VoidA 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.
| Name | Type |
|---|---|
value |
Dynamic |
message |
haxe.extern.Rest |
clear(): VoidWhen stdout is a TTY, calling console.clear() will attempt to clear the TTY. When stdout is not a TTY, this method does nothing.
Maintains an internal counter specific to label and outputs to stdout the number of times console.count() has been called with the given label.
| Name | Type | Default |
|---|---|---|
label |
String | (optional) |
Resets the internal counter specific to label.
| Name | Type | Default |
|---|---|---|
label |
String | (optional) |
debug(data: Dynamic, args: haxe.extern.Rest): VoidThe console.debug() function is an alias for console.log().
| Name | Type |
|---|---|
data |
Dynamic |
args |
haxe.extern.Rest |
dir(obj: Dynamic, ?options: Null<js.node.InspectOptionsBase>): VoidUses util.inspect() on obj and prints the resulting string to stdout. This function bypasses any custom inspect() function defined on obj.
| Name | Type | Default |
|---|---|---|
obj |
Dynamic | |
options |
Null<js.node.InspectOptionsBase> | (optional) |
dirxml(data: haxe.extern.Rest): VoidThis method calls console.log() passing it the arguments received. This method does not produce any XML formatting.
| Name | Type |
|---|---|
data |
haxe.extern.Rest |
error(data: Dynamic, args: haxe.extern.Rest): VoidPrints 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()).
| Name | Type |
|---|---|
data |
Dynamic |
args |
haxe.extern.Rest |
group(label: haxe.extern.Rest): VoidIf one or more labels are provided, those are printed first without the additional indentation.
| Name | Type |
|---|---|
label |
haxe.extern.Rest |
groupCollapsed(): VoidAn alias for console.group().
groupEnd(): VoidDecreases indentation of subsequent lines by two spaces.
info(data: Dynamic, args: haxe.extern.Rest): VoidThe console.info() function is an alias for console.log().
| Name | Type |
|---|---|
data |
Dynamic |
args |
haxe.extern.Rest |
log(data: Dynamic, args: haxe.extern.Rest): VoidPrints 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()).
| Name | Type |
|---|---|
data |
Dynamic |
args |
haxe.extern.Rest |
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.
| Name | Type | Default |
|---|---|---|
tabularData |
Dynamic | |
properties |
Array<String> | (optional) |
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.
| Name | Type | Default |
|---|---|---|
label |
String | (optional) |
Stops a timer that was previously started by calling console.time() and prints the result to stdout:
| Name | Type | Default |
|---|---|---|
label |
String | (optional) |
timeLog(?label: String, data: haxe.extern.Rest): VoidFor a timer that was previously started by calling console.time(), prints the elapsed time and other data arguments to stdout:
| Name | Type | Default |
|---|---|---|
label |
String | (optional) |
data |
haxe.extern.Rest |
trace(message: Dynamic, args: haxe.extern.Rest): VoidPrints to stderr the string 'Trace: ', followed by the util.format() formatted message and stack trace to the current position in the code.
| Name | Type |
|---|---|
message |
Dynamic |
args |
haxe.extern.Rest |
warn(data: Dynamic, args: haxe.extern.Rest): VoidThe console.warn() function is an alias for console.error().
| Name | Type |
|---|---|
data |
Dynamic |
args |
haxe.extern.Rest |
This method does not display anything unless used in the inspector. The console.markTimeline() method is the deprecated form of console.timeStamp().
| Name | Type | Default |
|---|---|---|
label |
String | (optional) |
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.
| Name | Type | Default |
|---|---|---|
label |
String | (optional) |
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.
| Name | Type | Default |
|---|---|---|
label |
String | (optional) |
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.
| Name | Type | Default |
|---|---|---|
label |
String | (optional) |
This method does not display anything unless used in the inspector. The console.timeline() method is the deprecated form of console.time().
| Name | Type | Default |
|---|---|---|
label |
String | (optional) |
This method does not display anything unless used in the inspector. The console.timelineEnd() method is the deprecated form of console.timeEnd().
| Name | Type | Default |
|---|---|---|
label |
String | (optional) |
new(stdout: js.node.stream.IWritable, ?stderr: js.node.stream.IWritable, ?ignoreerrors: Bool): VoidCreates 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.
| Name | Type | Default |
|---|---|---|
stdout |
js.node.stream.IWritable | |
stderr |
js.node.stream.IWritable | (optional) |
ignoreerrors |
Bool | (optional) |
Metadata
| Name | Parameters |
|---|---|
:jsRequire |
"console", "Console" |