console

This class allows the developer to write to the Execution log and to [Google Cloud Logging](https://cloud.google.com/logging) if the script is associated with
a [standard
Cloud Project](https://developers.google.com/apps-script/guides/cloud-platform-projects#standard).

For full support of Cloud Logging and structured logging, use `https://developers.google.com/apps-script/reference/base/logger`. The `console` methods
serialize the objects to strings and do not support `jsonPayload` as part of the structured
logging [`LogEntry`](https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry).

```javascript
function measuringExecutionTime() {
  const label = "myFunction() time"; // Labels the timing log entry.
  console.time(label); // Starts the timer.
  try {
    myFunction(); // Function to time.
  } catch (e) {
    // Logs an ERROR message.
    console.error("myFunction() yielded an error: " + e);
  }
  console.timeEnd(label); // Stops the timer, logs execution duration.
}

function myFunction() {
  // ...
}
```

### Methods

| Method | Return type | Brief description |
|---|---|---|
| `https://developers.google.com/apps-script/reference/base/console#error()` | `void` | Outputs a blank ERROR level message to Stackdriver Logging. |
| `https://developers.google.com/apps-script/reference/base/console#error(Object,Object...)` | `void` | Outputs an ERROR level message to Stackdriver Logging. |
| `https://developers.google.com/apps-script/reference/base/console#info()` | `void` | Outputs blank INFO level message to Stackdriver Logging. |
| `https://developers.google.com/apps-script/reference/base/console#info(Object,Object...)` | `void` | Outputs an INFO level message to Stackdriver Logging. |
| `https://developers.google.com/apps-script/reference/base/console#log()` | `void` | Outputs a blank DEBUG level message to Stackdriver Logging. |
| `https://developers.google.com/apps-script/reference/base/console#log(Object,Object...)` | `void` | Outputs a DEBUG level message to Stackdriver Logging. |
| `https://developers.google.com/apps-script/reference/base/console#time(String)` | `void` | Starts a timer you can use to track how long an operation takes. |
| `https://developers.google.com/apps-script/reference/base/console#timeEnd(String)` | `void` | Stops a timer that was previously started by calling `console.time()`. |
| `https://developers.google.com/apps-script/reference/base/console#warn()` | `void` | Outputs a blank WARNING level message to Stackdriver Logging. |
| `https://developers.google.com/apps-script/reference/base/console#warn(Object,Object...)` | `void` | Outputs a WARNING level message to Stackdriver Logging. |

## Detailed documentation

### `error()`

Outputs a blank ERROR level message to Stackdriver Logging.

*** ** * ** ***

### `error(formatOrObject, values)`

Outputs an ERROR level message to Stackdriver Logging.

#### Parameters

| Name | Type | Description |
|---|---|---|
| `formatOrObject` | `Object` | A string containing zero or more substitution strings, or a JavaScript object to be logged as a JavaScript object if no other parameters. |
| `values` | `Object...` | Objects with which to replace substitution strings within the message. This gives you additional control over the format of the output. |

*** ** * ** ***

### `info()`

Outputs blank INFO level message to Stackdriver Logging.

*** ** * ** ***

### `info(formatOrObject, values)`

Outputs an INFO level message to Stackdriver Logging.

#### Parameters

| Name | Type | Description |
|---|---|---|
| `formatOrObject` | `Object` | A string containing zero or more substitution strings, or a JavaScript object to be logged as a JavaScript object if no other parameters. |
| `values` | `Object...` | Objects with which to replace substitution strings within the message. This gives you additional control over the format of the output. |

*** ** * ** ***

### `log()`

Outputs a blank DEBUG level message to Stackdriver Logging.

*** ** * ** ***

### `log(formatOrObject, values)`

Outputs a DEBUG level message to Stackdriver Logging.

#### Parameters

| Name | Type | Description |
|---|---|---|
| `formatOrObject` | `Object` | A string containing zero or more substitution strings, or a JavaScript object to be logged as a JavaScript object if no other parameters. |
| `values` | `Object...` | Objects with which to replace substitution strings within the message. This gives you additional control over the format of the output. |

*** ** * ** ***

### `time(label)`

Starts a timer you can use to track how long an operation takes.

#### Parameters

| Name | Type | Description |
|---|---|---|
| `label` | `String` | The name to give the new timer. |

*** ** * ** ***

### `timeEnd(label)`

Stops a timer that was previously started by calling `console.time()`. The time duration
is logged in Stackdriver.

#### Parameters

| Name | Type | Description |
|---|---|---|
| `label` | `String` | The name of the timer to stop. |

*** ** * ** ***

### `warn()`

Outputs a blank WARNING level message to Stackdriver Logging.

*** ** * ** ***

### `warn(formatOrObject, values)`

Outputs a WARNING level message to Stackdriver Logging.

#### Parameters

| Name | Type | Description |
|---|---|---|
| `formatOrObject` | `Object` | A string containing zero or more substitution strings, or a JavaScript object to be logged as a JavaScript object if no other parameters. |
| `values` | `Object...` | Objects with which to replace substitution strings within the message. This gives you additional control over the format of the output. |