# Custom script messages for logs

## Introduction

When testing and debugging scripts, it can be useful to write specific information to logs after the script has finished processing.&#x20;

You can do this by adding a `logs` array key to a script, with required output added as strings - for example:

{% code title="PHP" overflow="wrap" lineNumbers="true" %}

```php
function handle($data)
{
    $data['logs'] = ["Log message 1", "Log message 2"];
    return $data;
}
```

{% endcode %}

...is output as:

<figure><img src="/files/89bGb877HDRzh3ciVhAi" alt=""><figcaption></figcaption></figure>

## Need to know

* Log messages must be strings.
* A maximum of 500 characters (in total) is allowed.
* Use with care (especially in loops) as logs are output every time the script runs.


---

# 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://doc.wearepatchworks.com/product-documentation/developer-hub/custom-scripting/creating-and-testing-custom-scripts/custom-script-messages-for-logs.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.
