Usage
Send events, levels, optional fields, and client options with @oleq-ai/logs
Send events
await log.info({ message: "server started" });
await log.warn({ message: "slow query", body: { ms: 420 } });
await log.error({
message: "payment failed",
kind: "res",
body: { status: 402 },
});
await log.flush();Call flush() before process exit or in serverless handlers so batched events are sent.
Levels
Pass as type on the event, or call the matching method (log.info(…), log.error(…), …).
tracedebuginfosuccesswarnerrorfatalauditmetric
Legacy clients may send warning — ingest normalizes it to warn.
Optional fields
| Field | Notes |
|---|---|
kind | req or res — separate events; dashboard shows REQ / RES badges |
body | Any JSON-serializable attachment |
track / security / metrics | Structured blobs on the event |
Options
| Option | Required | Default |
|---|---|---|
appName | yes | — |
apiKey | no* | OLEQLOG_API_KEY |
baseUrl | no | production API |
environment | no | NODE_ENV or development |
flushIntervalMs | no | 2000 |
maxBatchSize | no | 50 |
ingestUrl | no | — (browser proxy mode; no API key on client) |
*Required unless OLEQLOG_API_KEY is set (or ingestUrl is used for proxy mode).
Adapters
Official subpath exports for Express, NestJS, Next.js, and React — middleware, modules, server helpers, and a client hook.
See Adapters for setup and code samples.
Pino
Already using Pino? See Pino transport — same package, worker thread, level mapping built in.
More recipes: Examples