Appearance
Log (ctx.log)
ctx.log writes structured log lines that operators can read after the run, on the surfaces listed below. print output is not displayed anywhere, and the type checker flags print as unknown.
| Function | Level |
|---|---|
ctx.log.info(message, attrs?) | INFO |
ctx.log.warn(message, attrs?) | WARNING |
ctx.log.error(message, attrs?) | ERROR |
The functions are synchronous and return nothing. attrs is an optional table of structured values.
lua
ctx.log.info("import started", { source = "erp", batch = 41 })
ctx.log.warn("row rejected", { row = 12, field = "quantity", value = -3 })
ctx.log.error("import aborted", { rejected = 1, reason = "invalid quantity" })
return { logged = 3 }- Keep the message a fixed phrase and put changing values in
attrs, so lines from different runs can be grouped and searched. ctx.log.errorrecords a line; it does not stop the script. Callerror(...)to stop.- A run keeps at most 100 log lines. Further lines are dropped, and a warning with the number of dropped lines is added.
Where the lines appear
| Surface | Where to read them |
|---|---|
Workflow script node | The workflow execution's logs, with the node recorded on each line |
| Lua Playground | The Logs panel (the logs field of the playground result) |
| Integration | The integration instance's logs |
| Incoming webhook, custom app server script | Not stored: the lines are discarded after the run |
Lines are kept even when the script fails afterwards, which is when they matter most.
When a platform call fails (for example a device that cannot be reached), the platform writes the detailed cause into the same log, while the script receives only a short message. Check the log first when a ctx call returns false.