logixlysia@6.15.0
Minor Changes
-
e4ff9a9:
aiMiddlewarerecordscacheReadTokensandcacheWriteTokenswhen the provider reports input tokens read from or written to its prompt cache. Both fields are part ofinputTokens, not extra tokens on top of it. They add up across the calls of a request,mergeAIMetricsaccepts them, and a provider that reports none leaves the line as it was. -
ae54eb6:
createAxiomTransport()acceptsedgeandedgeUrl, and readsAXIOM_EDGEandAXIOM_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 isedgeUrl, thenedge, thenbaseUrl. Passing any of the three as an option turns off all three endpoint variables (AXIOM_EDGE_URL,AXIOM_EDGE,AXIOM_URL), so abaseUrlwritten in code is never overruled by the shell. Anedgevalue that is not a plain domain, with an optional port, throws at creation; pass a full URL asedgeUrlinstead. -
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 mosttimeoutMsfor the flush and the close together, then resolves and reports the deadline throughonErrorwithsink: 'shutdown'. Every adapter’sflush()andclose()accept{ signal }: when it aborts,flush()resolves and leaves the request in flight to finish, andclose()aborts the request, ends a wait before a retry, drops what is still buffered, reports all of it in oneonDropped({ count, reason: 'closed' })and rejects.withRedactionpasses 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
flushTimeoutMsnow reaches the transports, so the retries it started stop holding the process once it stops waiting.flushLogixlysia(options)withouttimeoutMswaits as long as delivery takes, as before, and calls each transport’sflush()andclose()with no argument. -
4ced623:
logixlysia/otelnow adds the active span’s trace flags to the request context:trace_flags, the flags byte as two hex digits, andtrace_sampled, next totrace_idandspan_id. These are the fieldstraceparentEnricher()already adds. Before,otelEnricher()andinjectTraceContextleft them out, so an OTLP or HyperDX record for a span the SDK started never carried the nativeflagsfield. -
587bc5b: The configured
servicename reached the text line and the JSON console line, but not the record handed to transports, so a record shipped throughlogixlysia/http, a custom transport orcreateMemoryTransport()could not say which app wrote it. Every record a transport receives now carriesservicein itsmetawhenserviceis set, and it wins over aservicekey in the logged data. An adapter’s own service option, such as Datadog’sserviceor the OTLPserviceName, 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’sfailedcount).onDroppednow receives{ count, reason: 'rejected' }for those records, and the backend’s explanation goes toonError. The batch is not retried andflush()still resolves.createHttpTransporttakes a new optionalrejectedfunction 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 asRunJobOptions. -
5e225cd: With
sampling.tail.statusset, a request that ended in an error logged atERRORnow counts as a500for that comparison when the client got a status below400. A generator or SSE response that failed after a2xxstatus and its first chunk went out, or an error anonErrorhook answered with a redirect, keeps its sampled-away lines under a threshold of500or less.tail.keepreceives a newerrorfield with the value that was thrown, except for a thrownstatus()result, which is a response. Which lines are kept does not change for a request whose client got400or more, or for a thrownstatus()result. -
6a9bfb3: Add
logixlysia/testing, withcreateMemoryTransportfor asserting on logs in tests. It keeps the lastmaxRecordsrecords (default 1000) as plain snapshots withlevel,message,method,path,status,durationMs,requestId, the mergedcontextand the serializederror, including thecode,whyandfixof anHttpError. Records carry the redactionautoRedactapplied. Read them withrecords,find,filter,lastandclear, orawait waitFor(predicate), which rejects aftertimeoutMswith the records it saw.
Patch Changes
- 9f321ac:
mergeAIMetrics(log, …)andmergeAIMetrics(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’saifields: 5 and 7 input tokens were logged asinputTokens: 7withcalls: 1.aiMiddleware(log)records through the first form, so a handler that used it and also reported another SDK throughstore.loggerlogged too few tokens. Totals are kept per plugin instance: when an app forwards a request to another app that has its ownlogixlysia(), and both report throughstore.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 inBETTER_STACK_INGESTING_HOSTand inendpoint, and sends to it overhttps. Before, a bare host such ass123456.eu-nbg-2.betterstackdata.commade the adapter throwinvalid endpoint URLat 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
autoRedactcheaper 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 theprodpreset 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=cjsas AWS CDK’sNodejsFunctiondoes by default, crashed at import withTypeError [ERR_INVALID_ARG_VALUE]fromcreateRequire. The package root has done this since 6.14.0 andlogixlysia/otelsince it was added. Such a bundle now imports, handles requests and writes console, file andstore.pinolines, pretty printing included. Three things stay off in it: the colors of the plugin’s own console lines (prettystore.pinolines 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.5and 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
formaterror. Reading and merging the returned fields now sits inside the same guard as the enricher call, so the error goes toonErrorwith sinkenricher, 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.excludeorsampling.tail.pathsstopped the app with a bareInvalid 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 waylogFilter.includeandlogFilter.excludealready were:logixlysia: invalid sampling config — tail.paths: '/a/**/**/x' — Invalid glob pattern: …. Thetail.pathsglobs are checked only when head sampling drops records (asampling.headrate 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 aresolve,deriveoronRequesthook answered is logged with the status the client received and without an error. Before, the line’s message was the source text of Elysia’sstatushelper, and aResponsereturned fromonRequestwas logged asERRORwith status200whatever 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-basedmaxFilescounts an uncompressed archive’s age from its last write, so a file that sat idle for longer thanmaxFilesis deleted whenintervalrotates it; before, the write that triggered the rotation made it look new.maxSizerotation is unchanged. - 384126e: With
consoleFormat: 'json', amessagein the data passed tostore.logger.logthat is not a string replaced the line’smessage, so the line carried an object or a number there. The line’smessageis now always a string: the data’smessagewhen 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
onDroppedwith the batch size and reasonsend-failed. Previously the batch counted as delivered even though Loki stored none of it. - 70ac17e:
createMemoryTransport()fromlogixlysia/testingnow keeps the promise its type makes:record.error.messageis 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.erroris still exactly what the transport received. - 065e732: With
pino.prettyPrinton and nopino.transport, lines written throughstore.pinonow show atimestamp.translateTimepattern the same way the text console line does. Before,SSSprinted as letters, a pattern without a prefix was rendered in UTC, letters between tokens were replaced, andUTC:standardprinted nonsense. Two tokens side by side, such asmmmm, 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[]).standardis 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. AtranslateTimeset insidepino.prettyPrintis unchanged. - 8d5268e: The README’s testing example now lists every key of a memory record, including
metaandtimestamp, and the README says that on Elysia 2logandstorework 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.loghas keys of those names. Before, withconsoleFormat: 'json',{ level: 'DEBUG', timestamp: 'x' }in the data printed a line with that level and that timestamp, and arequestkey 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
requestIdon, 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 withaot: falsethe replaced value was written to the response header unchecked, so a value with a line break made the request throw. A mergedrequestIdis now ignored; use another key, such asupstreamRequestId, for another service’s id. ArequestIdpassed to a single log call still labels that one line. - 4bcd818: The adapters and
createHttpTransportnow retry a408 Request Timeoutresponse like a429, 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.Zrow 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 showshttp://localhost:3000or thePORTvariable’s port, which could differ from the port the app listens on; it is printed without a URL instead. - 2437a42: With
autoRedacton and nopino.redactset,store.pinomasked only the exact built-in key names andredactKeysentries, at the top level and one level down, so keys such asaccessToken,apiKey,x_api_keyandAuthorization, or a nesteduser.profile.password, were written in clear text. The object passed as the first argument to astore.pinocall, 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 atoJSON, an array passed as the first argument, top-level keys that have a pino serializer, child bindings,pino.baseandmixinfields. 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_COLORorNO_COLORbeing 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
minLevelwhen the plugin is created. Before, only the built-in adapters andcreateHttpTransportchecked it, so{ log, minLevel: 'error' }inconfig.transportswas accepted and then received every level. AminLevelthat is notDEBUG,INFO,WARNINGorERRORnow throwslogixlysia: invalid output config. - a4e25ed: With
logErrorPayload: true, a failed validation is now logged with theValidation 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 abodyvalidation, but also the value of a failedquery,headers,params,cookieorresponsevalidation), or a schema’s customerrortext, whereautoRedactcannot mask a value by its key. The submitted value is now inerror.foundand the failures inerror.errors, each with only itspathandmessage, on the structured record (the JSON console line and what transports receive). WithautoRedacton, keys such aspasswordinsidefoundare masked and every failure’smessageis replaced by[REDACTED], because a validator’s message can quote what was submitted; turnautoRedactoff to read the messages. A failure’spathand the summary message are logged on both settings and are not masked by key. An application error that only carriescode: 'VALIDATION', with no validation data, keeps its own message,codeandstatus. If you read the JSON text out of the message, read these fields instead.error.codeanderror.statusno longer appear on a validation error’s object; for a request the plugin logs, the record’s ownstatusstill does. - 61cf037: The description of
withRedaction’sonErroroption now says what it covers: load and redaction failures, a throw or rejection from the wrapped transport’slog(), and a record dropped because the queue is full. A record logged afterclose()is reported throughonDroppedonly, as before. - ce27af3: A
wrapWshook that throws or rejects is now logged as anERRORline with no status, whose message names the hook and the error (WebSocket message hook failed: boom) and which carries the error in itserrorfield, instead of anINFOline with status 200 and no error. Anopenormessagehook that returns a generator is logged when its iteration ends, with anERRORline if it throws partway, and a generator Elysia never finishes gets no line. Aclosehook 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 withoutwrapWs, and a hook’s error still reaches Elysia’sonError.