# Logging & debugging

Studio records what your code does on every request, so you can see exactly why a notification was — or wasn't — sent.

## console.log

Use `console.log(...)` (and `console.warn`, `console.error`) anywhere in your code. The output is captured **per request** and shown in the **Console** tab of [Request history](/introduction/justpush-studio/testing-and-monitoring/request-history.md).

```javascript
console.log("Incoming event:", request.body.event)

if (!request.body.user) {
    console.warn("No user in payload")
    return
}

console.log("Sending notification for", request.body.user)
return {
    title: "New activity",
    message: request.body.user
}
```

## What each request records

For every webhook that arrives, Studio stores:

* the request **method**, **headers**, and **body** (what came in),
* your code's **console output** (what it logged),
* the **status / result** of the run, and
* which **revision** of your code handled it.

Open any request in the [request history](/introduction/justpush-studio/testing-and-monitoring/request-history.md) to inspect all of this.

## A debugging loop that works

1. Send a real (or [test](/introduction/justpush-studio/testing-and-monitoring/testing-your-code.md)) request.
2. Open it in request history and read the **Console** tab.
3. Add `console.log` lines around the part that's misbehaving.
4. **Save** a new revision and send the request again.

## Common things to check

* **Reading the wrong field.** Log `request.body` to see the actual structure the provider sends — it's often nested.
* **Nothing returned.** If your code never returns a message (or hits an early `return`), no notification is sent. That's expected for filtered events, but log a line so you know it was intentional.
* **Wrong revision live.** Make sure you **saved** after your last edit — the editor shows "Not saved yet" until you do. See [Revisions](/introduction/justpush-studio/revisions/revisions.md).


---

# Agent Instructions: 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:

```
GET https://docs.justpush.io/introduction/justpush-studio/writing-code/logging-and-debugging.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
