---
changelog:
  category: Release
  version: logixlysia@6.15.0
date: '2026-11-28T11:33:32Z'
seo:
  description: >-
    aiMiddleware records cacheReadTokens and cacheWriteTokens when the provider
    reports input tokens read from or written to its prompt cache. Both fields
    are…
title: logixlysia@6.15.0
type: changelog
---
## Minor Changes

- e4ff9a9: `aiMiddleware` records `cacheReadTokens` and `cacheWriteTokens` when the provider reports input tokens read from or written to its prompt cache. Both fields are part of `inputTokens`, not extra tokens on top of it. They add up across the calls of a request, `mergeAIMetrics` accepts them, and a provider that reports none leaves the line as it was.
- ae54eb6: `createAxiomTransport()` accepts `edge` and `edgeUrl`, and reads `AXIOM_EDGE` and `AXIOM_EDGE_URL`, to ingest through an Axiom edge deployment at `/v1/ingest/{dataset}`. Before, the adapter always used the legacy path `/v1/datasets/{dataset}/ingest`, which Axiom documents as ingesting into US East 1. The order is `edgeUrl`, then `edge`, then `baseUrl`. Passing any of the three as an option turns off all three endpoint variables (`AXIOM_EDGE_URL`, `AXIOM_EDGE`, `AXIOM_URL`), so a `baseUrl` written in code is never overruled by the shell. An `edge` value that is not a plain domain, with an optional port, throws at creation; pass a full URL as `edgeUrl` instead.
- 8406e66: The built-in log file could only hold the text line, so a log shipper that tails it or a tool that reads logs had to parse a custom layout, and redirecting the JSON console to a file loses rotation. The new `fileFormat: 'json'` option writes the JSON console line to the file, one object per line, with the same keys, order and redaction. Rotation, retention and file modes are unchanged. The default stays `'text'` and no preset changes it.
- be8daf5: `flushLogixlysia(options, { close: true, timeoutMs })` now waits at most `timeoutMs` for the flush and the close together, then resolves and reports the deadline through `onError` with `sink: 'shutdown'`. Every adapter's `flush()` and `close()` accept `{ signal }`: when it aborts, `flush()` resolves and leaves the request in flight to finish, and `close()` aborts the request, ends a wait before a retry, drops what is still buffered, reports all of it in one `onDropped({ count, reason: 'closed' })` and rejects. `withRedaction` passes the signal on to the transport it wraps.
  
  Without opting in, a send that nobody awaits, such as one started by a full batch or by the interval timer, no longer holds the process open while it waits to retry, and the stop hook's `flushTimeoutMs` now reaches the transports, so the retries it started stop holding the process once it stops waiting.
  
  `flushLogixlysia(options)` without `timeoutMs` waits as long as delivery takes, as before, and calls each transport's `flush()` and `close()` with no argument.
- 4ced623: `logixlysia/otel` now adds the active span's trace flags to the request context: `trace_flags`, the flags byte as two hex digits, and `trace_sampled`, next to `trace_id` and `span_id`. These are the fields `traceparentEnricher()` already adds. Before, `otelEnricher()` and `injectTraceContext` left them out, so an OTLP or HyperDX record for a span the SDK started never carried the native `flags` field.
- 587bc5b: The configured `service` name reached the text line and the JSON console line, but not the record handed to transports, so a record shipped through `logixlysia/http`, a custom transport or `createMemoryTransport()` could not say which app wrote it. Every record a transport receives now carries `service` in its `meta` when `service` is set, and it wins over a `service` key in the logged data. An adapter's own service option, such as Datadog's `service` or the OTLP `serviceName`, still names the service in that backend.
- 4bcd818: The OTLP, HyperDX and Axiom adapters no longer count records as delivered when the backend answers with success but reports that it rejected some of them (an OTLP `partialSuccess`, or Axiom's `failed` count). `onDropped` now receives `{ count, reason: 'rejected' }` for those records, and the backend's explanation goes to `onError`. The batch is not retried and `flush()` still resolves.
  
  `createHttpTransport` takes a new optional `rejected` function for other backends. It receives the parsed JSON body of a successful response and returns `{ count, detail? }` for the entries the backend did not store.
- 66b0340: `runJob(name, fn, { successLine: false })` writes no final line for a job that returns, so a job that runs often can report failures only. A job that throws still gets its error line, and lines the job logs itself are written as before. The option's type is exported as `RunJobOptions`.
- 5e225cd: With `sampling.tail.status` set, a request that ended in an error logged at `ERROR` now counts as a `500` for that comparison when the client got a status below `400`. A generator or SSE response that failed after a `2xx` status and its first chunk went out, or an error an `onError` hook answered with a redirect, keeps its sampled-away lines under a threshold of `500` or less. `tail.keep` receives a new `error` field with the value that was thrown, except for a thrown `status()` result, which is a response. Which lines are kept does not change for a request whose client got `400` or more, or for a thrown `status()` result.
- 6a9bfb3: Add `logixlysia/testing`, with `createMemoryTransport` for asserting on logs in tests. It keeps the last `maxRecords` records (default 1000) as plain snapshots with `level`, `message`, `method`, `path`, `status`, `durationMs`, `requestId`, the merged `context` and the serialized `error`, including the `code`, `why` and `fix` of an `HttpError`. Records carry the redaction `autoRedact` applied. Read them with `records`, `find`, `filter`, `last` and `clear`, or `await waitFor(predicate)`, which rejects after `timeoutMs` with the records it saw.

## Patch Changes

- 9f321ac: `mergeAIMetrics(log, …)` and `mergeAIMetrics(store.logger, request, …)` now add to the same totals within a request. Before, each form kept its own, and the later call replaced the earlier one's `ai` fields: 5 and 7 input tokens were logged as `inputTokens: 7` with `calls: 1`. `aiMiddleware(log)` records through the first form, so a handler that used it and also reported another SDK through `store.logger` logged too few tokens. Totals are kept per plugin instance: when an app forwards a request to another app that has its own `logixlysia()`, and both report through `store.logger`, the app that receives the request no longer has the forwarding app's usage added to its own.
- d0459c1: `createBetterStackTransport()` now accepts an ingesting host without a scheme in `BETTER_STACK_INGESTING_HOST` and in `endpoint`, and sends to it over `https`. Before, a bare host such as `s123456.eu-nbg-2.betterstackdata.com` made the adapter throw `invalid endpoint URL` at startup.
- 8961e08: When tail sampling buffers a record that carries a `durationOverride`, the buffered record now keeps that override, as the write path already did. The plugin's own replay never buffers such a record, so app logs are unchanged.
- 2b5af6f: Make `autoRedact` cheaper again on the per-request path. Text that cannot hold a secret (a method, a path segment, a request id) skips the secret rules, a host name is no longer run through the IPv4 pattern, and a request URL with a plain query is checked as text instead of parsed. The redacted output is the same. In a local run a request through the `prod` preset took about 12% less time with no query, and between 29% (Node) and 54% (Bun) less with one.
- ba66191: An app bundled to CommonJS, for example by esbuild with `--format=cjs` as AWS CDK's `NodejsFunction` does by default, crashed at import with `TypeError [ERR_INVALID_ARG_VALUE]` from `createRequire`. The package root has done this since 6.14.0 and `logixlysia/otel` since it was added. Such a bundle now imports, handles requests and writes console, file and `store.pino` lines, pretty printing included. Three things stay off in it: the colors of the plugin's own console lines (pretty `store.pino` lines keep theirs), gzip compression of rotated files (the rotated file is kept and the failure is reported as a rotation error) and the OpenTelemetry trace fields. The startup banner shows no version numbers there.
- 06416db: The README did not say that on Elysia `2.0.0-rc.5` and later a WebSocket route needs Bun 1.4.4 or newer. On an older Bun the upgrade request answers 500 and the socket never opens, with or without Logixlysia. The README's Elysia 2 passage now says so.
- 81336fb: An adapter endpoint that cannot be parsed and carries `user:password@` without a scheme, such as `//user:password@host/path`, is reported as `<redacted>@host/path`. Before, the credentials were masked only when the value started with a scheme, so the error printed them.
- a2d3d04: The error for an adapter endpoint URL that does not parse printed the URL's query string and fragment, so a key passed as `?api_key=…` reached stderr and any error reporter. The message now shows `?<redacted>` or `#<redacted>` in their place, and only the scheme when an `@` follows that `?` or `#`, since a password may itself contain one. A logged field named `__proto__` was dropped when an adapter flattened a record into attributes, and it is now kept as an ordinary field.
- fd4f7a5: An enricher that returned fields which threw while being read, such as a getter that fails, was not caught. It stopped the enrichers after it from running. In the request phase the error became the response body. In the response phase it was reported as a `format` error. Reading and merging the returned fields now sits inside the same guard as the enricher call, so the error goes to `onError` with sink `enricher`, the request goes on, and the next enricher still runs.
- 863219d: A log line written while `flushLogixlysia(options, { close: true })` was running could reopen the log file while its sink was still registered, and the close then stopped tracking that sink, so later closes by the plugin could no longer reach the reopened file descriptor. Such a line now keeps its sink registered, and the next close releases the descriptor.
- 7efde8f: An invalid glob in `logFilter.accessLine.include`, `logFilter.accessLine.exclude` or `sampling.tail.paths` stopped the app with a bare `Invalid glob pattern: …` error that named neither the package nor the option. Such a glob is now rejected when the options are resolved, with a message that names the option and the glob, the same way `logFilter.include` and `logFilter.exclude` already were: `logixlysia: invalid sampling config — tail.paths: '/a/**/**/x' — Invalid glob pattern: …`. The `tail.paths` globs are checked only when head sampling drops records (a `sampling.head` rate below 100), the only case in which they are compiled, so a config that started before still starts.
- 982ee30: With `aot: false`, a request that a `resolve`, `derive` or `onRequest` hook answered is logged with the status the client received and without an error. Before, the line's message was the source text of Elysia's `status` helper, and a `Response` returned from `onRequest` was logged as `ERROR` with status `200` whatever its own status was.
- ef4558c: With `logRotation.interval`, a write after the interval elapsed was appended before the file was archived, so the whole batch landed in the previous period. The interval is now checked before the write, and that batch starts the new file. An empty file whose interval has already elapsed is still not archived, and its period now starts at that first write instead of archiving the line on its own. Time-based `maxFiles` counts an uncompressed archive's age from its last write, so a file that sat idle for longer than `maxFiles` is deleted when `interval` rotates it; before, the write that triggered the rotation made it look new. `maxSize` rotation is unchanged.
- 384126e: With `consoleFormat: 'json'`, a `message` in the data passed to `store.logger.log` that is not a string replaced the line's `message`, so the line carried an object or a number there. The line's `message` is now always a string: the data's `message` when it is a string, and empty otherwise.
- 1f531a1: The built-in Loki transport now treats HTTP 260, Loki's default response when ingestion is blocked, as a failed push. It does not retry the batch and calls `onDropped` with the batch size and reason `send-failed`. Previously the batch counted as delivered even though Loki stored none of it.
- 70ac17e: `createMemoryTransport()` from `logixlysia/testing` now keeps the promise its type makes: `record.error.message` is always a string. An error whose message is an object or a number gets it as JSON text, an error without a message gets `''`, and an error logged as a plain string becomes `{ message }` instead of being dropped. `record.meta.error` is still exactly what the transport received.
- 065e732: With `pino.prettyPrint` on and no `pino.transport`, lines written through `store.pino` now show a `timestamp.translateTime` pattern the same way the text console line does. Before, `SSS` printed as letters, a pattern without a prefix was rendered in UTC, letters between tokens were replaced, and `UTC:standard` printed nonsense. Two tokens side by side, such as `mmmm`, are read as two tokens, and a pattern that is only a prefix (`SYS:`) leaves the time empty on both lines (the pino line shows `[]`). `standard` is accepted in any letter case (`SYS:STANDARD`) on both lines; on the pino line it keeps pino-pretty's own form, which ends with the zone offset. A `translateTime` set inside `pino.prettyPrint` is unchanged.
- 8d5268e: The README's testing example now lists every key of a memory record, including `meta` and `timestamp`, and the README says that on Elysia 2 `log` and `store` work at run time but are not yet part of a handler's context type. No code changed.
- c019a4f: A record keeps its own level, timestamp and request when the data passed to `store.logger.log` has keys of those names. Before, with `consoleFormat: 'json'`, `{ level: 'DEBUG', timestamp: 'x' }` in the data printed a line with that level and that timestamp, and a `request` key replaced the record's `{ method, url }` on the JSON line and in what every transport received. The library's values now win; other keys in the data are logged as before.
- c0e3cc8: With `requestId` on, the id the plugin read or generated can no longer be replaced through the request's context, so a request's log lines and its response header carry the same id. Before, `log.mergeContext({ requestId })` or an enricher returning that field replaced it for the rest of the request, and on an app built with `aot: false` the replaced value was written to the response header unchecked, so a value with a line break made the request throw. A merged `requestId` is now ignored; use another key, such as `upstreamRequestId`, for another service's id. A `requestId` passed to a single log call still labels that one line.
- 4bcd818: The adapters and `createHttpTransport` now retry a `408 Request Timeout` response like a `429`, with the usual backoff. Before, a 408 ended the send without another attempt.
- 6a516de: With the plugin mounted in more than one module, the routes of a later instance logged without the request id and without its enrichers' fields, sampled each line on its own instead of each request as a whole, and its tail rules could not rescue the handler's lines (the final line was still written). A later instance now opens its own request scope when its derive runs for a request, so its routes log like the first instance's routes. Instances in one request share one request id per header name, whatever the case of the name, so the response carries one id.
- 38cec54: The startup banner now shows its `logixlysia vX.Y.Z` row from an installed package. The row was only ever printed when running from the repository's source, because the version was looked up one directory too high from the built file. Under an adapter that gives start hooks no server, such as `@elysiajs/node`, the message no longer shows `http://localhost:3000` or the `PORT` variable's port, which could differ from the port the app listens on; it is printed without a URL instead.
- 2437a42: With `autoRedact` on and no `pino.redact` set, `store.pino` masked only the exact built-in key names and `redactKeys` entries, at the top level and one level down, so keys such as `accessToken`, `apiKey`, `x_api_key` and `Authorization`, or a nested `user.profile.password`, were written in clear text. The object passed as the first argument to a `store.pino` call, or to a call on a child logger, is now also masked by the same key rule as the plugin's own lines, at any depth, wherever it is plain data. What the walk does not look inside stays on pino's path redaction as before: class instances, errors, objects with a getter or a `toJSON`, an array passed as the first argument, top-level keys that have a pino serializer, child bindings, `pino.base` and `mixin` fields. Everything that was masked before is still masked, and a call with nothing to mask hands pino the same object.
- e082e24: The package's tests no longer depend on `FORCE_COLOR` or `NO_COLOR` being unset in the shell that runs them. Nothing changes for users of the package.
- e6a9be3: A transport you write yourself is now checked for a valid `minLevel` when the plugin is created. Before, only the built-in adapters and `createHttpTransport` checked it, so `{ log, minLevel: 'error' }` in `config.transports` was accepted and then received every level. A `minLevel` that is not `DEBUG`, `INFO`, `WARNING` or `ERROR` now throws `logixlysia: invalid output config`.
- a4e25ed: With `logErrorPayload: true`, a failed validation is now logged with the `Validation failed (…)` summary as its message, the same as with the option off. Before, on Elysia 1.4, the message was Elysia's own validation message, which by default is a JSON text that includes the value that failed (the request body for a `body` validation, but also the value of a failed `query`, `headers`, `params`, `cookie` or `response` validation), or a schema's custom `error` text, where `autoRedact` cannot mask a value by its key. The submitted value is now in `error.found` and the failures in `error.errors`, each with only its `path` and `message`, on the structured record (the JSON console line and what transports receive). With `autoRedact` on, keys such as `password` inside `found` are masked and every failure's `message` is replaced by `[REDACTED]`, because a validator's message can quote what was submitted; turn `autoRedact` off to read the messages. A failure's `path` and the summary message are logged on both settings and are not masked by key. An application error that only carries `code: 'VALIDATION'`, with no validation data, keeps its own message, `code` and `status`. If you read the JSON text out of the message, read these fields instead. `error.code` and `error.status` no longer appear on a validation error's object; for a request the plugin logs, the record's own `status` still does.
- 61cf037: The description of `withRedaction`'s `onError` option now says what it covers: load and redaction failures, a throw or rejection from the wrapped transport's `log()`, and a record dropped because the queue is full. A record logged after `close()` is reported through `onDropped` only, as before.
- ce27af3: A `wrapWs` hook that throws or rejects is now logged as an `ERROR` line with no status, whose message names the hook and the error (`WebSocket message hook failed: boom`) and which carries the error in its `error` field, instead of an `INFO` line with status 200 and no error. An `open` or `message` hook that returns a generator is logged when its iteration ends, with an `ERROR` line if it throws partway, and a generator Elysia never finishes gets no line. A `close` hook is logged when it returns or its promise settles and does not wait on a generator it returns. Only a plain generator is wrapped: a hand-written iterator, a generator from another realm and a generator that carries properties of its own are returned unchanged and logged when the hook returns. What a hook returns is sent as it is without `wrapWs`, and a hook's error still reaches Elysia's `onError`.
