> For the complete documentation index, see [llms.txt](https://dev.ubidots.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://dev.ubidots.com/ubifunctions/getting-started/logs.md).

# Logs

A great debugging resource is the ability to view your function logs. To do so, go to the left sidebar and select the **Logs** icon, as shown below, to view your function's execution history:

<figure><img src="https://884329393-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MhzNRg0B4ECiNXc093G%2Fuploads%2Fm5rmvN8bqNp82vhevZIW%2Fimage.png?alt=media&amp;token=b73358da-99ee-41c2-9307-5bb4b8529697" alt=""><figcaption></figcaption></figure>

In the function logs, you can confirm that data was successfully posted to Ubidots with the **201** response code:

<figure><img src="https://884329393-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MhzNRg0B4ECiNXc093G%2Fuploads%2FZwOMVcVvsB14lIhZbTb0%2Fimage.png?alt=media&amp;token=0573fc87-c245-49f2-b911-a7dc3d88bfa1" alt=""><figcaption></figcaption></figure>

This is what your function returns. It must be in JSON dictionary format. In your code, make sure to use **return** to exit the function and return the dictionary.

<figure><img src="https://884329393-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MhzNRg0B4ECiNXc093G%2Fuploads%2Fw9115XwiecGDz4qy299a%2Fimage.png?alt=media&amp;token=e30d6203-d4a9-4ab8-a008-c0580a2c56f8" alt="" width="257"><figcaption></figcaption></figure>

{% tabs %}
{% tab title="NodeJS" %}

```javascript
return response.data;
```

{% endtab %}

{% tab title="Python" %}

```python
return {"status": "Ok", "result": req.json()}
```

{% endtab %}
{% endtabs %}

You can also use logs for debugging. Print any variables defined earlier, or print any message that needs to be displayed to the user.

<figure><img src="https://884329393-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MhzNRg0B4ECiNXc093G%2Fuploads%2FR1obT6T7PQBvTQNRUG9W%2Fimage.png?alt=media&amp;token=bf2fdd05-aad7-4b92-affa-2878a88ddea6" alt=""><figcaption></figcaption></figure>

{% tabs %}
{% tab title="NodeJS" %}

```javascript
console.log("[INFO] Request result:");
console.log(response);
```

{% endtab %}

{% tab title="Python" %}

```python
print("[INFO] Request result:")
print(req.text)
```

{% endtab %}
{% endtabs %}


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://dev.ubidots.com/ubifunctions/getting-started/logs.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
