# Global.Console

> Console logging facilities.

- Source: https://titaniumsdk.com/docs/sdk/12.7.1/Global.Console
- Titanium SDK version: 12.7.1
- Kind: module
- Platforms: Android, iPhone, iPad, macOS
- Since: Titanium SDK 2.1.0

The toplevel `console` support is intended to supplement [Titanium.API](https://titaniumsdk.com/docs/sdk/Titanium.API.md)
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](https://developer.mozilla.org/de/docs/Web/API/Console) specification.
See the following supported methods for details and submit a pull request to add more!

## Methods

### assert

- Platforms: Android, iPhone, iPad, macOS
- Since: Titanium SDK 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:

- `value` (any, optional): The value tested for being truthy. Default: `default`.
- `message` (any, optional, repeatable): All arguments besides value are used as error message.

### count

- Platforms: Android, iPhone, iPad, macOS
- Since: Titanium SDK 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:

- `label` (String, optional): The display label for the counter Default: `default`.

### countReset

- Platforms: Android, iPhone, iPad, macOS
- Since: Titanium SDK 9.1.0

Resets the internal counter specific to `label`.

Parameters:

- `label` (String, optional): The display label for the counter Default: `default`.

### debug

- Platforms: Android, iPhone, iPad, macOS

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:

- `message` (any, repeatable): The message(s) to log.

### error

- Platforms: Android, iPhone, iPad, macOS

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:

- `message` (any, repeatable): The message(s) to log.

### group

- Platforms: Android, iPhone, iPad, macOS
- Since: Titanium SDK 9.1.0

Increases indentation of subsequent lines by spaces for `groupIndentation` length.

Parameters:

- `label` (any, optional, repeatable): Labels to print before indentation (if provided)

### groupCollapsed

- Platforms: Android, iPhone, iPad, macOS
- Since: Titanium SDK 9.1.0

Alias for `group()`

Parameters:

- `label` (any, optional, repeatable): Labels to print before indentation (if provided)

### groupEnd

- Platforms: Android, iPhone, iPad, macOS
- Since: Titanium SDK 9.1.0

Decreases indentation of subsequent lines by spaces for `groupIndentation` length.

### info

- Platforms: Android, iPhone, iPad, macOS

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:

- `message` (any, repeatable): The message(s) to log.

### log

- Platforms: Android, iPhone, iPad, macOS

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](https://titaniumsdk.com/docs/sdk/Titanium.API.md#log),
which can take multiple arguments, but in doing so interprets the
first argument as a custom log level.

Parameters:

- `message` (any, repeatable): The message(s) to log.

### time

- Platforms: Android, iPhone, iPad, macOS
- Since: Titanium SDK 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:

- `label` (String, optional): The label to track the timer by Default: `default`.

### timeEnd

- Platforms: Android, iPhone, iPad, macOS
- Since: Titanium SDK 7.3.0

Stop a timer that was previously started.

Stop a timer that was started by calling [console.time](https://titaniumsdk.com/docs/sdk/Global.Console.md#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:

- `label` (String, optional): The label to track the timer by Default: `default`.

### timeLog

- Platforms: Android, iPhone, iPad, macOS
- Since: Titanium SDK 7.5.0

Log duration taken so far for an operation.

Output the time since a timer was started by calling
[console.time](https://titaniumsdk.com/docs/sdk/Global.Console.md#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:

- `label` (String, optional): The label to track the timer by Default: `default`.
- `data` (any, optional, repeatable): Extra log data to be provided when logging, can be a single argument or any number of arguments.

### trace

- Platforms: Android, iPhone, iPad, macOS
- Since: Titanium SDK 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:

- `message` (any, repeatable): The message(s) to log.

### warn

- Platforms: Android, iPhone, iPad, macOS

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:

- `message` (any, repeatable): The message(s) to log.

---

- This corpus documents Titanium SDK 13.4.1. Anything here that does not name a version describes 13.4.1.
- Titanium is maintained by TiDev. The Appcelerator toolchain is retired: there is no `appc` CLI, no Appcelerator Studio and no hosted build service. The supported CLI is `titanium` on npm, invoked as `ti`.

