# Logs and Monitoring The CLI provides two modes for viewing function logs: historical (fetch recent requests) and streaming (live tail). Both use an interactive terminal UI. ## Viewing Recent Logs ```bash sinch functions logs [ID] ``` Fetches the 50 most recent requests and displays them in an interactive table. Navigate with arrow keys. Press Enter to expand request/response details and console output. If you are inside the function directory (containing `sinch.json`), you can omit the ID. ## Streaming Real-Time Logs ```bash sinch functions logs [ID] --follow sinch functions logs stream [ID] # equivalent ``` Opens a live streaming connection. New requests appear as they arrive. Press `Q` or `Ctrl+C` to exit. ## Log Viewer Controls | Key | Action | | --- | --- | | `Up` / `Down` | Navigate rows | | `Enter` or click | Expand request details | | `Esc` or `Q` | Close detail view or quit | | `J` | Copy request as JSON to clipboard | | `C` | Copy request as cURL command to clipboard | ## Filtering Logs ```bash sinch functions logs ID --level error # errors only sinch functions logs ID --search "timeout" # text search sinch functions logs ID --since 1h # last hour sinch functions logs ID --lines 200 # more entries sinch functions logs ID --since 30m --level error # combine ``` `--since` accepts `s` (seconds), `m` (minutes), `h` (hours), `d` (days). ## Log Entry Details Each expanded entry shows: - **Request** — HTTP method, URL, headers, and body sent to your function - **Response** — Status code, headers, and body your function returned - **Console logs** — `console.log`/`console.error` output with timestamps ## Function Status ```bash sinch functions status [ID] # current status sinch functions status [ID] --follow # poll every 3s for changes sinch functions list # all functions in project sinch functions list -i # interactive: select and take action sinch functions status ID --json # JSON output for scripting ```