Logs (totalum-sdk/logs)
import … from 'totalum-sdk/logs' — or the same namespace on totalum from 'totalum-sdk'. Install, configuration and errors: Totalum SDK.
Read your app's own server logs: the requests the published app (env: 'live') or the preview ('dev') handled,
with their console lines, status codes and errors. Use it for an admin page that shows recent errors, or to debug.
Free.
const { items } = await totalum.logs.query({ level: 'error', env: 'live' });| Method or type | What it does |
|---|---|
totalumLogs | Creates the logs namespace (the same object as totalum.logs, scope logs:read): the requests the published app (env: 'live') or the preview ('dev') handled, with their console lines and errors. |
logs.query | Reads the app's server logs, newest first: one item per request (or per console line), with its level, message, path, status and timings. |
LogsPage | Log items from logs.query(). |
LogsQuery | A logs.query filter: the time window (default the last hour), level, text, status, path, request id and environment; every field is optional. |
#totalumLogs
totalumLogs(options?: TotalumClientOptions): TotalumLogsCreates the logs namespace (the same object as totalum.logs, scope logs:read): the requests the published app
(env: 'live') or the preview ('dev') handled, with their console lines and errors. Free.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
options | TotalumClientOptions | no | The project key, API URL and environment; each falls back to its environment variable. |
options.key | string | no | Project key tlm_pk_…; default TOTALUM_PROJECT_KEY. Server-side only. |
options.apiUrl | string | no | The Totalum API's URL: default TOTALUM_SDK_API_URL, else https://sdk-api.totalum.app. |
options.env | 'dev' | 'live' | no | Sent as x-totalum-env on every call (the database it targets, and dev vs live usage); default TOTALUM_ENV, else live. |
Returns TotalumLogs — The logs namespace: the method below.
Example
import { totalumLogs } from 'totalum-sdk/logs';
const logs = totalumLogs();
const { items } = await logs.query({ level: 'error' });The namespace's type is exported as TotalumLogs (import type { TotalumLogs } from 'totalum-sdk/logs').
#logs.query
logs.query(q?: LogsQuery): Promise<LogsPage>Reads the app's server logs, newest first: one item per request (or per console line), with its level,
message, path, status and timings. Use it for an admin "recent errors" page or to debug. window in the answer
is the window actually searched. Free.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
q | LogsQuery | no | The filters; all optional. |
q.limit | number | no | At most this many items. Default 100. Allowed: ≥ 1, ≤ 500. |
q.status | string | no | Only requests with this HTTP status (500) or class (5xx). |
q.env | 'dev' | 'live' | no | live (the published app, default) or dev (the preview). |
q.requestId | string | no | Only this request (from a TotalumError.requestId, or a log item). Allowed: at most 64 characters. |
q.source | 'live' | 'auto' | 'buffer' | no | auto (default), buffer (the last hours, fast) or live. |
q.to | string | no | The window's end; default now. Allowed: ISO 8601 date-time. |
q.from | string | no | The window's start; default one hour before to. Allowed: ISO 8601 date-time. |
q.level | 'error' | 'log' | 'debug' | 'info' | 'warn' | no | Only this level: error, warn, info, log or debug. |
q.q | string | no | Only items whose message contains this text. Allowed: at most 200 characters. |
q.path | string | no | Only requests to this path (/api/orders). Allowed: at most 512 characters. |
Returns Promise<LogsPage> — Up to limit (≤ 500) log items and the window searched.
| Field | Type | Always present | Description |
|---|---|---|---|
items | ({ ts, level, message, requestId, method, path, status, cpuMs, wallMs, outcome, exception? })[] | yes | The items, newest first. |
items.ts | string | yes | When it happened. |
items.level | 'error' | 'log' | 'debug' | 'info' | 'warn' | yes | error, warn, info, log or debug. |
items.message | string | yes | The log line (secrets are redacted). |
items.requestId | string | null | yes | The request it belongs to. |
items.method | string | null | yes | The request's HTTP method. |
items.path | string | null | yes | The request's path. |
items.status | number | null | yes | The HTTP status the app answered. |
items.cpuMs | number | null | yes | CPU time the request used, in ms. |
items.wallMs | number | null | yes | Total time the request took, in ms. |
items.outcome | string | yes | How the request ended (ok, exception, exceededCpu, canceled). |
items.exception | { name, message, stack? } | no | The uncaught error, when there was one. |
items.exception.name | string | yes | Its name (TypeError). |
items.exception.message | string | yes | Its message. |
items.exception.stack | string | no | Its stack trace. |
window | { from, to, source } | yes | The window actually searched. |
window.from | string | yes | Its start. |
window.to | string | yes | Its end. |
window.source | 'live' | 'buffer' | yes | Where the items came from: buffer (recent) or live. |
nextCursor | string | null | yes | Always null today: narrow the window to see more. |
sampled | boolean | yes | Whether only a sample of the items was kept (very busy apps). |
hint | string | no | A tip when nothing matched (a wider window, the other environment). |
Errors — besides the errors every call can throw:
| Code | HTTP | When |
|---|---|---|
VALIDATION_ERROR | 400 | A filter has the wrong format (status must look like 500 or 5xx). |
LOGS_UPSTREAM_ERROR | 502 | Logs are unavailable; retry shortly. |
Example
const { items } = await totalum.logs.query({ level: 'error', env: 'live', limit: 2 });Result:
{
"items": [
{
"ts": "2026-10-11T17:20:41.118Z",
"level": "error",
"message": "TypeError: Cannot read properties of undefined (reading 'id')",
"requestId": "8f1c2a9e4b7d3c6a",
"method": "POST",
"path": "/api/orders",
"status": 500,
"cpuMs": 4.1,
"wallMs": 37.9,
"outcome": "ok",
"exception": { "name": "TypeError", "message": "Cannot read properties of undefined (reading 'id')" }
}
],
"window": { "from": "2026-10-11T16:38:39.984Z", "to": "2026-10-11T17:38:39.984Z", "source": "live" },
"nextCursor": null,
"sampled": false
}#LogsPage
Log items from logs.query().
| Field | Type | Always present | Description |
|---|---|---|---|
items | ({ ts, level, message, requestId, method, path, status, cpuMs, wallMs, outcome, exception? })[] | yes | The items, newest first. |
items.ts | string | yes | When it happened. |
items.level | 'error' | 'log' | 'debug' | 'info' | 'warn' | yes | error, warn, info, log or debug. |
items.message | string | yes | The log line (secrets are redacted). |
items.requestId | string | null | yes | The request it belongs to. |
items.method | string | null | yes | The request's HTTP method. |
items.path | string | null | yes | The request's path. |
items.status | number | null | yes | The HTTP status the app answered. |
items.cpuMs | number | null | yes | CPU time the request used, in ms. |
items.wallMs | number | null | yes | Total time the request took, in ms. |
items.outcome | string | yes | How the request ended (ok, exception, exceededCpu, canceled). |
items.exception | { name, message, stack? } | no | The uncaught error, when there was one. |
items.exception.name | string | yes | Its name (TypeError). |
items.exception.message | string | yes | Its message. |
items.exception.stack | string | no | Its stack trace. |
window | { from, to, source } | yes | The window actually searched. |
window.from | string | yes | Its start. |
window.to | string | yes | Its end. |
window.source | 'live' | 'buffer' | yes | Where the items came from: buffer (recent) or live. |
nextCursor | string | null | yes | Always null today: narrow the window to see more. |
sampled | boolean | yes | Whether only a sample of the items was kept (very busy apps). |
hint | string | no | A tip when nothing matched (a wider window, the other environment). |
#LogsQuery type
A logs.query filter: the time window (default the last hour), level, text, status, path, request id and
environment; every field is optional.
| Name | Type | Required | Description |
|---|---|---|---|
limit | number | no | At most this many items. Default 100. Allowed: ≥ 1, ≤ 500. |
status | string | no | Only requests with this HTTP status (500) or class (5xx). |
env | 'dev' | 'live' | no | live (the published app, default) or dev (the preview). |
requestId | string | no | Only this request (from a TotalumError.requestId, or a log item). Allowed: at most 64 characters. |
source | 'live' | 'auto' | 'buffer' | no | auto (default), buffer (the last hours, fast) or live. |
to | string | no | The window's end; default now. Allowed: ISO 8601 date-time. |
from | string | no | The window's start; default one hour before to. Allowed: ISO 8601 date-time. |
level | 'error' | 'log' | 'debug' | 'info' | 'warn' | no | Only this level: error, warn, info, log or debug. |
q | string | no | Only items whose message contains this text. Allowed: at most 200 characters. |
path | string | no | Only requests to this path (/api/orders). Allowed: at most 512 characters. |
