> ## Documentation Index
> Fetch the complete documentation index at: https://docs.lionlang.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# console module: logging from Lion programs

> Lion's console module provides log for printing strings and log-json for pretty-printing any value as formatted JSON to the console.

The `console` module gives Lion programs a way to emit output during evaluation. Both functions write to the console and then return the logged value, so they can be used inside a `begin` block without discarding a result you still need.

## Functions

### `console/log`

Logs a message string to the console and returns the message.

```json theme={null}
["console/log", "hello"]
```

Output: `hello`

Return value: `"hello"`

***

### `console/log-json`

Pretty-prints any value as JSON with two-space indentation, then returns the formatted string. Useful for inspecting objects and arrays during development.

```json theme={null}
["console/log-json", {"hello": "world"}]
```

Output:

```json theme={null}
{
  "hello": "world"
}
```

Return value: `"{\n  \"hello\": \"world\"\n}"`

## Logging inside a sequence

Because both functions return the value they log, you can place them inside a `begin` block without interrupting the flow of your program:

```json theme={null}
["begin",
  ["define", "result", ["number/add", 1, 2]],
  ["console/log-json", "result"],
  "result"]
```

<Note>
  `console/log` and `console/log-json` use Effect's `Console.log` under the hood. In test environments that provide a custom Effect console layer, output may be captured rather than printed to stdout.
</Note>

<Tip>
  During development, wrap intermediate values with `console/log-json` to inspect them in place. Remove the wrapper once you are satisfied with the result — the surrounding expression is unaffected because both functions return the value they receive.
</Tip>
