# Global.Console
Console logging facilities.
# 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
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
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
Resets the internal counter specific to label
.
Parameters
Name | Type | Description |
---|---|---|
label | String | The display label for the counter |
Returns
- Type
- void
# debug
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
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
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
Alias for group()
Parameters
Name | Type | Description |
---|---|---|
label | any | Labels to print before indentation (if provided) |
Returns
- Type
- void
# groupEnd
Decreases indentation of subsequent lines by spaces for groupIndentation
length.
Returns
- Type
- void
# info
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
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
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
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
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
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
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