> For the complete documentation index, see [llms.txt](https://osl.mistium.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://osl.mistium.com/commands/debugging.md).

# Debugging (log / say)

The `log` command prints a value to standard output. It is the OSL equivalent of `print` in Python or `console.log` in JavaScript, and is the main tool for inspecting values while developing a script.

```javascript
log "hello world"
```

`say` is an alias for `log`:

```javascript
say "hello world"   // same as log
```

## Logging any value

`log` accepts any value. Arrays and objects are printed as JSON, numbers and booleans as their literal form.

```javascript
log 42                 // 42
log [1, 2, 3]          // [1,2,3]
log { a: 1, b: 2 }     // {"a":1,"b":2}
log true               // true
```

## Building log messages

Use `++` to join a string with another value without adding a space (the value is converted to a string automatically):

```javascript
auto x = 5
log "x is " ++ x       // x is 5
```

## warn and error

`warn` and `error` work exactly like `log` - they take any number of values and format them the same way - but they write to **standard error** instead of standard output. Use them for diagnostics so they stay out of a program's normal output and can be redirected separately.

```javascript
log "result"            // -> stdout
warn "low on memory"    // -> stderr
error "request failed"  // -> stderr
```

```javascript
def check(n) (
  if n < 0 (
    error "value must not be negative"
    return
  )
  log n
)
```

`warn` and `error` are identical; the two names just signal intent. Both let the script keep running - to stop execution, use `throw`. For structured or levelled logging, see the [`osl/log`](/packages/terminal/log.md) package.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://osl.mistium.com/commands/debugging.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
