Docs
BlogHomeStart building

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.

ts
const { items } = await totalum.logs.query({ level: 'error', env: 'live' });
Method or typeWhat it does
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.
logs.queryReads the app's server logs, newest first: one item per request (or per console line), with its level, message, path, status and timings.
LogsPageLog items from logs.query().
LogsQueryA logs.query filter: the time window (default the last hour), level, text, status, path, request id and environment; every field is optional.

#totalumLogs

ts
totalumLogs(options?: TotalumClientOptions): 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. Free.

Parameters

NameTypeRequiredDescription
optionsTotalumClientOptionsnoThe project key, API URL and environment; each falls back to its environment variable.
options.keystringnoProject key tlm_pk_…; default TOTALUM_PROJECT_KEY. Server-side only.
options.apiUrlstringnoThe Totalum API's URL: default TOTALUM_SDK_API_URL, else https://sdk-api.totalum.app.
options.env'dev' | 'live'noSent 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

ts
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

ts
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

NameTypeRequiredDescription
qLogsQuerynoThe filters; all optional.
q.limitnumbernoAt most this many items. Default 100. Allowed: ≥ 1, ≤ 500.
q.statusstringnoOnly requests with this HTTP status (500) or class (5xx).
q.env'dev' | 'live'nolive (the published app, default) or dev (the preview).
q.requestIdstringnoOnly this request (from a TotalumError.requestId, or a log item). Allowed: at most 64 characters.
q.source'live' | 'auto' | 'buffer'noauto (default), buffer (the last hours, fast) or live.
q.tostringnoThe window's end; default now. Allowed: ISO 8601 date-time.
q.fromstringnoThe window's start; default one hour before to. Allowed: ISO 8601 date-time.
q.level'error' | 'log' | 'debug' | 'info' | 'warn'noOnly this level: error, warn, info, log or debug.
q.qstringnoOnly items whose message contains this text. Allowed: at most 200 characters.
q.pathstringnoOnly requests to this path (/api/orders). Allowed: at most 512 characters.

Returns Promise<LogsPage> — Up to limit (≤ 500) log items and the window searched.

FieldTypeAlways presentDescription
items({ ts, level, message, requestId, method, path, status, cpuMs, wallMs, outcome, exception? })[]yesThe items, newest first.
items.tsstringyesWhen it happened.
items.level'error' | 'log' | 'debug' | 'info' | 'warn'yeserror, warn, info, log or debug.
items.messagestringyesThe log line (secrets are redacted).
items.requestIdstring | nullyesThe request it belongs to.
items.methodstring | nullyesThe request's HTTP method.
items.pathstring | nullyesThe request's path.
items.statusnumber | nullyesThe HTTP status the app answered.
items.cpuMsnumber | nullyesCPU time the request used, in ms.
items.wallMsnumber | nullyesTotal time the request took, in ms.
items.outcomestringyesHow the request ended (ok, exception, exceededCpu, canceled).
items.exception{ name, message, stack? }noThe uncaught error, when there was one.
items.exception.namestringyesIts name (TypeError).
items.exception.messagestringyesIts message.
items.exception.stackstringnoIts stack trace.
window{ from, to, source }yesThe window actually searched.
window.fromstringyesIts start.
window.tostringyesIts end.
window.source'live' | 'buffer'yesWhere the items came from: buffer (recent) or live.
nextCursorstring | nullyesAlways null today: narrow the window to see more.
sampledbooleanyesWhether only a sample of the items was kept (very busy apps).
hintstringnoA tip when nothing matched (a wider window, the other environment).

Errors — besides the errors every call can throw:

CodeHTTPWhen
VALIDATION_ERROR400A filter has the wrong format (status must look like 500 or 5xx).
LOGS_UPSTREAM_ERROR502Logs are unavailable; retry shortly.

Example

ts
const { items } = await totalum.logs.query({ level: 'error', env: 'live', limit: 2 });

Result:

json
{
  "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().

FieldTypeAlways presentDescription
items({ ts, level, message, requestId, method, path, status, cpuMs, wallMs, outcome, exception? })[]yesThe items, newest first.
items.tsstringyesWhen it happened.
items.level'error' | 'log' | 'debug' | 'info' | 'warn'yeserror, warn, info, log or debug.
items.messagestringyesThe log line (secrets are redacted).
items.requestIdstring | nullyesThe request it belongs to.
items.methodstring | nullyesThe request's HTTP method.
items.pathstring | nullyesThe request's path.
items.statusnumber | nullyesThe HTTP status the app answered.
items.cpuMsnumber | nullyesCPU time the request used, in ms.
items.wallMsnumber | nullyesTotal time the request took, in ms.
items.outcomestringyesHow the request ended (ok, exception, exceededCpu, canceled).
items.exception{ name, message, stack? }noThe uncaught error, when there was one.
items.exception.namestringyesIts name (TypeError).
items.exception.messagestringyesIts message.
items.exception.stackstringnoIts stack trace.
window{ from, to, source }yesThe window actually searched.
window.fromstringyesIts start.
window.tostringyesIts end.
window.source'live' | 'buffer'yesWhere the items came from: buffer (recent) or live.
nextCursorstring | nullyesAlways null today: narrow the window to see more.
sampledbooleanyesWhether only a sample of the items was kept (very busy apps).
hintstringnoA 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.

NameTypeRequiredDescription
limitnumbernoAt most this many items. Default 100. Allowed: ≥ 1, ≤ 500.
statusstringnoOnly requests with this HTTP status (500) or class (5xx).
env'dev' | 'live'nolive (the published app, default) or dev (the preview).
requestIdstringnoOnly this request (from a TotalumError.requestId, or a log item). Allowed: at most 64 characters.
source'live' | 'auto' | 'buffer'noauto (default), buffer (the last hours, fast) or live.
tostringnoThe window's end; default now. Allowed: ISO 8601 date-time.
fromstringnoThe window's start; default one hour before to. Allowed: ISO 8601 date-time.
level'error' | 'log' | 'debug' | 'info' | 'warn'noOnly this level: error, warn, info, log or debug.
qstringnoOnly items whose message contains this text. Allowed: at most 200 characters.
pathstringnoOnly requests to this path (/api/orders). Allowed: at most 512 characters.