Skip to content
Titanium SDK
Titanium Docs
Version13.4.1

Global.Console

moduleAndroidiPhoneiPadmacOSsince 2.1.0

Console logging facilities.

The toplevel console support is intended to supplement Titanium.API and make it easier for developers to port existing JavaScript code (especially CommonJS modules) to Titanium.

Note that console does not currently implement the complete Console specification. See the following supported methods for details and submit a pull request to add more!

Methods 15

assert

since 9.1.0

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.

Parameters
ParametersTypeDescription
value?any

The value tested for being truthy.

message?any

All arguments besides value are used as error message.

count

since 9.1.0

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

Parameters
ParametersTypeDescription
label?String

The display label for the counter

countReset

since 9.1.0

Resets the internal counter specific to label.

Parameters
ParametersTypeDescription
label?String

The display label for the counter

Log a message at the debug level.

The message to log can either be a single argument, or any number of arguments, which will be converted to strings and then concatenated together with a space character.

Parameters
ParametersTypeDescription
messageany

The message(s) to log.

Log a message at the error level.

The message to log can either be a single argument, or any number of arguments, which will be converted to strings and then concatenated together with a space character.

Parameters
ParametersTypeDescription
messageany

The message(s) to log.

group

since 9.1.0

Increases indentation of subsequent lines by spaces for groupIndentation length.

Parameters
ParametersTypeDescription
label?any

Labels to print before indentation (if provided)

groupCollapsed

since 9.1.0

Alias for group()

Parameters
ParametersTypeDescription
label?any

Labels to print before indentation (if provided)

groupEnd

since 9.1.0

Decreases indentation of subsequent lines by spaces for groupIndentation length.

Log a message at the info level.

The message to log can either be a single argument, or any number of arguments, which will be converted to strings and then concatenated together with a space character.

Parameters
ParametersTypeDescription
messageany

The message(s) to log.

Log a message at the info level.

The message to log can either be a single argument, or any number of arguments, which will be converted to strings and then concatenated together with a space character.

Note that this method has different behavior from Titanium.API.log, which can take multiple arguments, but in doing so interprets the first argument as a custom log level.

Parameters
ParametersTypeDescription
messageany

The message(s) to log.

time

since 7.3.0

Start a timer to track duration of an operation.

Begin a timer that can be used to track the duration of an operation. If no label is passed to the function it will default to "default". If a label already exists then the existing label will not be overwritten and a warning will be logged to the console.

Parameters
ParametersTypeDescription
label?String

The label to track the timer by

timeEnd

since 7.3.0

Stop a timer that was previously started.

Stop a timer that was started by calling console.time, and output the time since the timer was begun to the console in milliseconds. If no timer exists a warning will be logged to the console.

Parameters
ParametersTypeDescription
label?String

The label to track the timer by

timeLog

since 7.5.0

Log duration taken so far for an operation.

Output the time since a timer was started by calling console.time to the console, as well as any other data arguments provided. To log extra data a label must be provided. If no timer exists a warning will be logged to the console.

Parameters
ParametersTypeDescription
label?String

The label to track the timer by

data?any

Extra log data to be provided when logging, can be a single argument or any number of arguments.

trace

since 9.1.0

Log a message at the trace level.

The message to log can either be a single argument, or any number of arguments, which will be converted to strings and then concatenated together with a space character.

Parameters
ParametersTypeDescription
messageany

The message(s) to log.

Log a message at the warn level.

The message to log can either be a single argument, or any number of arguments, which will be converted to strings and then concatenated together with a space character.

Parameters
ParametersTypeDescription
messageany

The message(s) to log.