# Global.Console

Console logging facilities.

Availability
2.1.0
2.1.0
9.2.0
Extends
Object

# Overview

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 (opens new window) specification. See the following supported methods for details and submit a pull request to add more!

# Methods

# assert

Availability
9.1.0
9.1.0
9.2.0
assert([value][, ...message]) 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.

Parameters

Name Type Description
value any

The value tested for being truthy.

message any

All arguments besides value are used as error message.

Returns

Type
void

# count

Availability
9.1.0
9.1.0
9.2.0
count([label]) 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.

Parameters

Name Type Description
label String

The display label for the counter

Returns

Type
void

# countReset

Availability
9.1.0
9.1.0
9.2.0
countReset([label]) void

Resets the internal counter specific to label.

Parameters

Name Type Description
label String

The display label for the counter

Returns

Type
void

# debug

Availability
2.1.0
2.1.0
9.2.0
debug(...message) void

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

Name Type Description
message any

The message(s) to log.

Returns

Type
void

# error

Availability
2.1.0
2.1.0
9.2.0
error(...message) void

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

Name Type Description
message any

The message(s) to log.

Returns

Type
void

# group

Availability
9.1.0
9.1.0
9.2.0
group([...label]) void

Increases indentation of subsequent lines by spaces for groupIndentation length.

Parameters

Name Type Description
label any

Labels to print before indentation (if provided)

Returns

Type
void

# groupCollapsed

Availability
9.1.0
9.1.0
9.2.0
groupCollapsed([...label]) void

Alias for group()

Parameters

Name Type Description
label any

Labels to print before indentation (if provided)

Returns

Type
void

# groupEnd

Availability
9.1.0
9.1.0
9.2.0
groupEnd() void

Decreases indentation of subsequent lines by spaces for groupIndentation length.

Returns

Type
void

# info

Availability
2.1.0
2.1.0
9.2.0
info(...message) void

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

Name Type Description
message any

The message(s) to log.

Returns

Type
void

# log

Availability
2.1.0
2.1.0
9.2.0
log(...message) void

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 log, which can take multiple arguments, but in doing so interprets the first argument as a custom log level.

Parameters

Name Type Description
message any

The message(s) to log.

Returns

Type
void

# time

Availability
7.3.0
7.3.0
9.2.0
time([label]) void

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

Name Type Description
label String

The label to track the timer by

Returns

Type
void

# timeEnd

Availability
7.3.0
7.3.0
9.2.0
timeEnd([label]) void

Stop a timer that was previously started.

Stop a timer that was started by calling 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

Name Type Description
label String

The label to track the timer by

Returns

Type
void

# timeLog

Availability
7.5.0
7.5.0
9.2.0
timeLog([label][, ...data]) void

Log duration taken so far for an operation.

Output the time since a timer was started by calling 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

Name Type Description
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.

Returns

Type
void

# trace

Availability
9.1.0
9.1.0
9.2.0
trace(...message) void

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

Name Type Description
message any

The message(s) to log.

Returns

Type
void

# warn

Availability
2.1.0
2.1.0
9.2.0
warn(...message) void

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

Name Type Description
message any

The message(s) to log.

Returns

Type
void