@bymax-one/nest-logger 1.4.30 → 1.4.32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -12,6 +12,31 @@ heading here.
12
12
 
13
13
  ## [Unreleased]
14
14
 
15
+ ## [1.4.32] - 2026-11-26
16
+
17
+ ### Documentation
18
+
19
+ - **Every log key is listed with its level and fields.** `LOGGER_BOOTSTRAP_OK` and `LOGGER_SHUTDOWN_OK` had no row, and `LOGGER_BUILTINS_REPLACED` is now listed under thrown errors.
20
+ - **The README fills gaps it had against the published types**, in the options, the HTTP fields, the decorators, the helpers and the destinations.
21
+ - **The row for `censorMessageText` is removed.** The method is marked `@internal`.
22
+ - **The comments on `ILogDestination` match the registry**, on write failure reports and on the shutdown budget.
23
+
24
+ No code change: against the published 1.4.31, the JavaScript in `dist/` is identical and the type declarations differ only in comments.
25
+
26
+ ## [1.4.31] - 2026-11-25
27
+
28
+ ### Changed
29
+
30
+ Both were measured against 1.4.30. For the input a real caller produces, the output is the same.
31
+
32
+ - **Hiding a message longer than the stack it is searched in costs more time.** The message is now cut to one character more than the stack before it is searched, so the table the search builds is bounded by the stack. Measured per call with a message of 10,000,000 characters: 0.009 ms to 1.41 ms for a concatenated message, 0.001 ms to 0.225 ms for a repeated pattern.
33
+ - **`PinoUnexpectedErrorSink` reads `error.getResponse` once.** It was read once to check its type and again to call it. An accessor that answers differently on the second read now gets the fields of its first answer.
34
+
35
+ ### Documentation
36
+
37
+ - **A body parser mounted after `app.init()` does not produce a parser entry; the README said it kept the parser's message.** Measured through `NestFactory` and real HTTP, with a malformed JSON body to a route: with Nest's default parser the answer is `400` and `HTTP_EXCEPTION_HANDLED` carries `bodyParserType: 'entity.parse.failed'`; with `express.json()` mounted after `app.init()`, and with no parser at all, the route runs with no parsed body (`201`) and no `HTTP_EXCEPTION_HANDLED` entry is written. Measured with the packed library in a scratch package, `@nestjs/platform-fastify` 11.2.9 and Fastify 5.12.8: the same malformed body answers `400` and `HTTP_EXCEPTION_HANDLED` carries Fastify's own message with no `bodyParserType`, and the response the filter writes fails with `res.status(...).json is not a function`. The Fastify adapter stays unsupported, so this is a documented limit (issue #211), not a gap to close. No code change.
38
+ - **`options.level` outside the Pino levels is refused.** Measured: `'verbose'`, `'silent'`, `'FATAL'` and the number `30` each make `forRoot` throw, and `'silent'` makes `forRootAsync` throw at bootstrap; the README did not say what happens to a value outside the levels. No code change.
39
+
15
40
  ## [1.4.30] - 2026-11-24
16
41
 
17
42
  ### Breaking
@@ -3561,7 +3586,9 @@ published `dist/` is identical — no runtime behaviour changes for consumers.
3561
3586
  - Professional CI suite: `ci.yml`, `bench.yml`, `codeql.yml`, `scorecard.yml`,
3562
3587
  `release.yml`, Dependabot, and issue templates
3563
3588
 
3564
- [Unreleased]: https://github.com/bymaxone/nest-logger/compare/v1.4.30...HEAD
3589
+ [Unreleased]: https://github.com/bymaxone/nest-logger/compare/v1.4.32...HEAD
3590
+ [1.4.32]: https://github.com/bymaxone/nest-logger/compare/v1.4.31...v1.4.32
3591
+ [1.4.31]: https://github.com/bymaxone/nest-logger/compare/v1.4.30...v1.4.31
3565
3592
  [1.4.30]: https://github.com/bymaxone/nest-logger/compare/v1.4.29...v1.4.30
3566
3593
  [1.4.29]: https://github.com/bymaxone/nest-logger/compare/v1.4.28...v1.4.29
3567
3594
  [1.4.28]: https://github.com/bymaxone/nest-logger/compare/v1.4.27...v1.4.28
package/README.md CHANGED
@@ -270,8 +270,8 @@ A key that holds `undefined` or `null` is read as not set, in the options and in
270
270
  | `resourceFormat` | `'nested' \| 'flat'` | `'nested'` | Shape of the identity fields. `'flat'` emits the dotted attribute names verbatim |
271
271
  | `eventNameField` | `string \| false` | `'event.name'` | Field carrying the derived event name (`PAYMENT_FAILED` → `payment.failed`). `false` disables it |
272
272
  | `errorFormat` | `'pino' \| 'semconv' \| 'both'` | `'pino'` | `'both'` adds `exception.*` and `error.type` beside `err.*`; `'semconv'` replaces them |
273
- | `level` | `LogLevel` | `'info'` when `NODE_ENV=production`, else `'debug'` | Minimum log level. One of `fatal \| error \| warn \| info \| debug \| trace` |
274
- | `redactPaths` | `string[]` | `[]` | Additional `fast-redact` paths, applied on top of the default coverage |
273
+ | `level` | `LogLevel` | `'info'` when `NODE_ENV=production`, else `'debug'` | Minimum log level. One of `fatal \| error \| warn \| info \| debug \| trace`, in lower case. Anything else, such as Pino's `silent`, `'FATAL'` or a numeric level, makes `forRoot` throw when it is called, and `forRootAsync` throw at bootstrap |
274
+ | `redactPaths` | `string[]` | `[]` | Additional `fast-redact` paths (each at most 256 characters), applied on top of the default coverage |
275
275
  | `redactStrategy` | `'names' \| 'paths'` | `'names'` | Engine behind the DEFAULT set. `'paths'` is the legacy `fast-redact` expansion (four-level ceiling, much slower) |
276
276
  | `shouldDisableDefaultRedact` | `boolean` | `false` | Skip the default PII coverage entirely. ⚠️ Emits `LOGGER_BOOTSTRAP_WARNING` at startup — document why |
277
277
  | `redactCensor` | `string` | `'[REDACTED]'` | Replacement value written in place of every redacted field |
@@ -325,10 +325,10 @@ A key that holds `undefined` or `null` is read as not set, in the options and in
325
325
 
326
326
  Shutdown first drains the queue each destination holds, and for the default stdout destination also what `process.stdout` has not yet handed to its reader, then calls each destination's `onShutdown` in reverse registration order. One budget covers the drain and every `onShutdown`, so the worst case is `shutdown.timeoutMs`, whatever the number of destinations. A destination reached after the budget is spent is named in one stderr line and its `onShutdown` is not called. Keep the budget below the grace period your platform gives the process, together with whatever else shuts down in it. Entries logged after the drain ended, by a host that logs in its own shutdown hook, are not waited for. Keep `shutdown.drainTimeoutMs` below `shutdown.timeoutMs`: a drain equal to the total, and a short total whose default drain is capped to it, leave no time for `onShutdown` when a queue never empties, and every `onShutdown` is then skipped and named.
327
327
 
328
- | Option | Type | Default | Description |
329
- | ------------------------- | -------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
330
- | `shutdown.timeoutMs` | `number` | `10000` | Total shutdown budget in ms, covering the drain and every `onShutdown` (an integer from 1 to 2147483647) |
331
- | `shutdown.drainTimeoutMs` | `number` | `5000` | Longest the drain may take, in ms, and not above `shutdown.timeoutMs`. When it ends with entries still queued, one stderr line names the destinations and the size of what each holds, and shutdown goes on |
328
+ | Option | Type | Default | Description |
329
+ | ------------------------- | -------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
330
+ | `shutdown.timeoutMs` | `number` | `10000` | Total shutdown budget in ms, covering the drain and every `onShutdown` (an integer from 1 to 2147483647) |
331
+ | `shutdown.drainTimeoutMs` | `number` | `5000` | Longest the drain may take, in ms, and not above `shutdown.timeoutMs`; left unset it is `timeoutMs` when that is below `5000`. When it ends with entries still queued, one stderr line names the destinations and the size of what each holds, and shutdown goes on |
332
332
 
333
333
  ### `destinationQueue` options
334
334
 
@@ -367,13 +367,13 @@ Set `http.isEnabled: true`, then wire the access log with `applyAccessLog(app)`
367
367
  | `HTTP_EXCEPTION_HANDLED` | `HttpException` below 500, or a thrown value that exposes a 4xx status, caught by the filter (`warn`) |
368
368
  | `HTTP_EXCEPTION_UNHANDLED` | `HttpException` of 500 or more, or any other thrown value, caught by the filter (`error`) |
369
369
 
370
- The levels are `info` for `HTTP_REQUEST_START`, `HTTP_REQUEST_SUCCESS` and `HTTP_REQUEST_REDIRECT`, `warn` for `HTTP_REQUEST_CLIENT_ERROR` and `HTTP_REQUEST_ABORTED`, and `error` for `HTTP_REQUEST_SERVER_ERROR`. A terminal entry carries `method`, `url`, `statusCode` and `duration`; a 4xx that threw adds `errorMessage`, and a 5xx the handler did not throw is logged with a synthesized `Error`. The exception entries carry `method`, `url` and `status`, and `bodyParserType` for a body that did not parse.
370
+ The levels are `info` for `HTTP_REQUEST_START`, `HTTP_REQUEST_SUCCESS` and `HTTP_REQUEST_REDIRECT`, `warn` for `HTTP_REQUEST_CLIENT_ERROR` and `HTTP_REQUEST_ABORTED`, and `error` for `HTTP_REQUEST_SERVER_ERROR`. `HTTP_REQUEST_START` carries `method`, `url`, `fullUrl`, `ip` and `userAgent` (`ip` is personal data). `HTTP_REQUEST_SERVER_ERROR` and `HTTP_EXCEPTION_UNHANDLED` carry the error as `err`. A terminal entry carries `method`, `url`, `statusCode` and `duration`; a 4xx thrown by a pipe or the handler adds `errorMessage`, and a 5xx that neither of them threw is logged with a synthesized `Error`. The exception entries carry `method`, `url` and `status`, and `bodyParserType` for some body-parser refusals.
371
371
 
372
372
  `HTTP_REQUEST_START` is emitted **before guards**, so it carries no `userId`: authentication runs in a guard and there is no principal yet. The acting user is on the terminal entry. Both entries carry the same `requestId`.
373
373
 
374
374
  URLs are normalized (`/users/550e8400-e29b-41d4-a716-446655440000` becomes `/users/:id`) so label cardinality stays bounded. The **query string is stripped** from every logged URL and from the message of a logged exception, because a magic-link token in a query parameter is a secret no key-name redaction can scrub out of a string. Only a literal `?` starts a query. A path segment that looks like a credential (a long hex value, a JWT, an opaque token, an email address, or a dotted token such as `ya29.…` or `v4.local.…` of which any dot-separated part is a long opaque token) is written as `:redacted` in `url`, `fullUrl` and the not-found message, and `http.secretPathSegments` adds your own patterns. `fullUrl` is the raw path without its query and with those segments replaced, not the request as received. A long camelCase or Pascal-case name cannot be told from a token and is replaced too. A secret the rules cannot see, such as `;jsessionid=...` in a segment, stays in `url`, and the message of a 5xx error is the application's own text, which is not scrubbed.
375
375
 
376
- For a body that does not parse (`entity.parse.failed`), one the parser's `verify` refuses (`entity.verify.failed`), or an unsupported content encoding or charset, `HTTP_EXCEPTION_HANDLED` carries a fixed message and the parser `type` in `bodyParserType`, because the parser's message can quote part of the body. While `HttpExceptionFilter` is registered it also writes the response: an `HttpException` keeps its own body, a thrown value that exposes a 4xx status becomes `{ statusCode, message }`, and any other error becomes `500 { statusCode: 500, message: 'Internal server error' }`; the application owns the response only when it registers no such filter. The malformed-JSON case needs the Express adapter and a body parser mounted before `app.init()`, as Nest's default one is; with another adapter, or a parser mounted after `app.init()`, that entry keeps the parser's message.
376
+ For a body that does not parse (`entity.parse.failed`), one the parser's `verify` refuses (`entity.verify.failed`), or an unsupported content encoding or charset, `HTTP_EXCEPTION_HANDLED` carries a fixed message and the parser `type` in `bodyParserType`, because the parser's message can quote part of the body. While `HttpExceptionFilter` is registered it also writes the response: an `HttpException` keeps its own body, a thrown value that exposes a 4xx status becomes `{ statusCode, message }`, and any other error becomes `500 { statusCode: 500, message: 'Internal server error' }`; the application owns the response only when it registers no such filter. The malformed-JSON case needs the Express adapter and a body parser mounted before `app.init()`, as Nest's default one is. The Fastify adapter is not supported: measured with `@nestjs/platform-fastify` 11.2.9 (Fastify 5.12.8), the same malformed body reaches `HTTP_EXCEPTION_HANDLED` with Fastify's own message and no `bodyParserType`, and the filter's response fails with `res.status(...).json is not a function`. A parser mounted after `app.init()` sits behind the router, so it never runs for a route that matches: that route handles the request without a parsed body (measured: a malformed JSON body to a route answered `201`, and no `HTTP_EXCEPTION_HANDLED` entry was written).
377
377
 
378
378
  > [!IMPORTANT]
379
379
  > **Why middleware and not an interceptor.** NestJS runs middleware → guards → interceptors → handler, so an interceptor never sees a request a guard rejected or one that matched no route. Measured against a real backend, 401, 403, 429 and 404 produced no log line at all, which hid brute force and route enumeration. Without the middleware wiring, the interceptor-based behaviour remains, blind spot included.
@@ -743,6 +743,8 @@ BymaxLoggerModule.forRootAsync({
743
743
 
744
744
  A non-empty `destinations` **replaces** `DefaultStdoutDestination`, so a file-only or socket-only deployment can turn structured stdout off. To keep stdout beside a custom sink, list it explicitly: `destinations: [new DefaultStdoutDestination(), new LokiDestination({ ... })]`.
745
745
 
746
+ `new DefaultStdoutDestination({ minLevel })` takes an optional minimum level; without one the module `level` applies. Its `name`, which `stderr` reports use, is `stdout-json`; `PrettyDevDestination` is named `pretty-dev`.
747
+
746
748
  A sink you supply may be the only one the application has, so two guarantees cover its failure: a destination that fails `onInit` is reported as `LOGGER_DESTINATION_INIT_FAILED` on `stderr` (not through the logger, whose sinks just failed) and receives no entries, and if **every** destination fails to initialize, entries fall back to raw NDJSON on `stdout`. Adding `new PrettyDevDestination()` without the optional `pino-pretty` therefore costs colours and a line on stderr, never your logs.
747
749
 
748
750
  ### Choosing how the dev terminal renders
@@ -1074,12 +1076,11 @@ Implements NestJS `LoggerService`. All methods are available via `@InjectLogger(
1074
1076
 
1075
1077
  **Helpers**
1076
1078
 
1077
- | Method | Signature | Notes |
1078
- | ------------------- | ------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
1079
- | `child` | `(bindings)` | New `PinoLoggerService` over a Pino child logger |
1080
- | `setContext` | `(context)` | Global label — ⚠️ singleton; prefer `@InjectLogger(MyClass.name)` |
1081
- | `getRawLogger` | `()` | The underlying Pino instance; bypasses the `meta` guards above |
1082
- | `censorMessageText` | `(text)` | The text with the censor of the `message` of an entry applied (`redactPaths`, `redactCensor`); use it before writing a free-text error to a channel the library does not own |
1079
+ | Method | Signature | Notes |
1080
+ | -------------- | ------------ | ----------------------------------------------------------------- |
1081
+ | `child` | `(bindings)` | New `PinoLoggerService` over a Pino child logger |
1082
+ | `setContext` | `(context)` | Global label — ⚠️ singleton; prefer `@InjectLogger(MyClass.name)` |
1083
+ | `getRawLogger` | `()` | The underlying Pino instance; bypasses the `meta` guards above |
1083
1084
 
1084
1085
  > [!NOTE]
1085
1086
  > There is no `fatalStructured` / `debugStructured`. Structured `fatal` and `debug` helpers are out of scope until a consumer needs them; use `getRawLogger()` in the meantime.
@@ -1098,11 +1099,11 @@ Implements NestJS `LoggerService`. All methods are available via `@InjectLogger(
1098
1099
 
1099
1100
  ### Decorators
1100
1101
 
1101
- | Decorator | Target | Description |
1102
- | ------------------------------- | ----------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
1103
- | `@InjectLogger(context?)` | Constructor param | Injects `PinoLoggerService` pre-bound to the given context string |
1104
- | `@LogContext(name)` | Class | **Deprecated.** Records a context label as class metadata that nothing in this package reads, so the label is never applied, and it does NOT open a `logContext.run()` scope. Use `@InjectLogger(MyClass.name)` for a per-class label |
1105
- | `@LogPerformance(thresholdMs?)` | Method | Logs `METHOD_EXECUTION` (`info`, fields `method` and `duration`) on completion; `METHOD_SLOW_EXECUTION` (`warn`, plus `thresholdMs`) if the duration is strictly greater than the threshold (1000 ms by default); the wrapped method always returns a `Promise`, so apply it to async methods. The threshold must be a finite number of zero or more (a `TypeError` at class definition otherwise) |
1102
+ | Decorator | Target | Description |
1103
+ | ------------------------------- | ----------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
1104
+ | `@InjectLogger(context?)` | Constructor param | Injects `PinoLoggerService` pre-bound to the given context string. A class that names a context must be imported before the `forRoot` / `forRootAsync` call is evaluated, which is when the contexts are collected |
1105
+ | `@LogContext(name)` | Class | **Deprecated.** Records a context label as class metadata that nothing in this package reads, so the label is never applied, and it does NOT open a `logContext.run()` scope. Use `@InjectLogger(MyClass.name)` for a per-class label |
1106
+ | `@LogPerformance(thresholdMs?)` | Method | Logs `METHOD_EXECUTION` (`info`, fields `method` and `duration`) on completion; `METHOD_SLOW_EXECUTION` (`warn`, plus `thresholdMs`) instead if the duration is strictly greater than the threshold (1000 ms by default); the wrapped method always returns a `Promise`, so apply it to async methods. The threshold must be a finite number of zero or more (a `TypeError` at class definition otherwise). A call that throws or rejects is logged the same way, with no outcome field, and the error is rethrown. The instance must hold a `PinoLoggerService` in a property named `logger`: without one, nothing is logged and no error is raised |
1106
1107
 
1107
1108
  ### Injection tokens and helpers
1108
1109
 
@@ -1122,12 +1123,12 @@ Every token is a `Symbol`, never a string, so it cannot collide with one of your
1122
1123
 
1123
1124
  ### Application helpers
1124
1125
 
1125
- | Helper | When to call it | Throws or stays silent |
1126
- | ------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
1127
- | `BymaxLoggerModule.useNestLogger(app)` | right after `NestFactory.create(AppModule, { bufferLogs: true })`; it calls `app.useLogger(logger)` and then `app.flushLogs()` | throws `[BymaxLoggerModule] useNestLogger(app) called but BymaxLoggerModule was not imported`, with the original error as `cause` |
1128
- | `BymaxLoggerModule.useRequestContext(app)` | before `app.init()`, when only the correlation scope is wanted | mounts the scope alone, with no access log |
1129
- | `applyAccessLog(app)` | before `app.init()` (or before `app.listen()` when `init()` is not called by you); it mounts the correlation scope and the access log together, ahead of the body parser | throws when the module was not imported. With `http.isEnabled` off it still opens the scope and writes no access entries. A mount after `init()` is not rejected: it mounts behind the parser and a request the parser refuses goes unlogged, with no error |
1130
- | `applyRequestIdMiddleware(consumer)` | in `configure(consumer)` of a module | mounts the request-id scope and the access log through the Nest middleware consumer |
1126
+ | Helper | When to call it | Throws or stays silent |
1127
+ | --------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
1128
+ | `BymaxLoggerModule.useNestLogger(app)` | right after `NestFactory.create(AppModule, { bufferLogs: true })`; it calls `app.useLogger(logger)` and then `app.flushLogs()` | throws `[BymaxLoggerModule] useNestLogger(app) called but BymaxLoggerModule was not imported`, with the original error as `cause` |
1129
+ | `BymaxLoggerModule.useRequestContext(app)` | before `app.init()`, when only the correlation scope is wanted | mounts the scope alone, with no access log |
1130
+ | `applyAccessLog(app)` | before `app.init()` (or before `app.listen()` when `init()` is not called by you); it mounts the correlation scope and the access log together, ahead of the body parser | throws when the module was not imported. With `http.isEnabled` off it still opens the scope and writes no access entries. A mount after `init()` is not rejected: it mounts behind the parser and the router, and a request the parser refuses or no route matches gets no access entry, with no error |
1131
+ | `applyRequestIdMiddleware(consumer, routes?)` | in `configure(consumer)` of a module | mounts the request-id scope and the access log through the Nest middleware consumer, on `routes` (default `/`, every route) |
1131
1132
 
1132
1133
  ### Option and context types (from `@bymax-one/nest-logger`)
1133
1134
 
@@ -1237,40 +1238,44 @@ interface ILogDestination {
1237
1238
 
1238
1239
  ## 🚨 Error Code Catalog
1239
1240
 
1240
- Two kinds of failure, and they surface differently. A **thrown `Error`** carries no code string: it carries a message prefixed with the emitting class, which is what you match on. A **log key** is a code you can filter on: it is written to `stderr` as a structured line, or into the envelope as `_logKey`.
1241
+ Two kinds of failure, and they surface differently. A **thrown `Error`** carries no code field: it carries a message prefixed with the emitting class, which is what you match on (`LOGGER_BUILTINS_REPLACED` is the whole message). A **log key** is a code you can filter on: it is the `logKey` of an entry or of a `stderr` line, or the `_logKey` of an envelope inside an entry.
1241
1242
 
1242
1243
  ### Thrown errors
1243
1244
 
1244
- | Message starts with | Thrown from | When | Action |
1245
- | -------------------------------------------------------- | ------------------------------------------- | ------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------- |
1246
- | `[BymaxLoggerModule] options.` | `forRoot` / `forRootAsync`, at module setup | any option fails validation: a missing `service`, a `level` outside the set, a bad type | Fix the option the message names; it prints the path and what it received |
1247
- | `[BymaxLoggerModule] options could not be read` | `forRoot` / `forRootAsync`, at module setup | an option the host supplies threw when it was read (a getter or a Proxy trap) | Fix the option; the error the host threw is the `cause` |
1248
- | `holds more than` | `forRoot` / `forRootAsync`, at module setup | a list option is longer than the entry cap (`MAX_LIST_ENTRIES`) | Shorten the list; it is refused before any element is read |
1249
- | `has a length that is not a count` | `forRoot` / `forRootAsync`, at module setup | a list option reports a length that is negative, fractional, `NaN` or infinite (a Proxy; an array never does) | Fix the option; it is refused before any element is read |
1250
- | `[BymaxLoggerModule] useNestLogger(app) called but` | `BymaxLoggerModule.useNestLogger` | the module was never imported into the application | Import `BymaxLoggerModule` before calling it |
1251
- | `[BymaxLoggerModule] applyAccessLog(app) called but` | `applyAccessLog` | the module was never imported into the application | Import `BymaxLoggerModule` before calling it |
1252
- | `[BymaxLoggerModule] useRequestContext(app) called but` | `useRequestContext` | the module was never imported into the application | Import `BymaxLoggerModule` before calling it |
1253
- | `[PrettyDevDestination] pino-pretty is not installed` | `PrettyDevDestination.onInit` | the destination is registered and resolving `pino-pretty` itself fails | Install `pino-pretty` or drop the destination |
1254
- | `[PrettyDevDestination] pino-pretty failed to start` | `PrettyDevDestination.onInit` | `pino-pretty` is found but importing it or building the transform throws | Read the message and the error's `cause`: it is the real failure |
1255
- | `[PrettyDevDestination] refused in production` | `PrettyDevDestination.onInit` | `NODE_ENV` is exactly `production` | Use `DefaultStdoutDestination` in production |
1256
- | `[LogContextService] set() called outside run() scope` | `LogContextService.set` | called with no active `run()` | Wrap the work in `logContext.run({ ... }, () => ...)` |
1257
- | `[LogContextService] Refusing to set unsafe context key` | `LogContextService.set` | the key is `__proto__`, `constructor` or `prototype` | Use an ordinary key |
1245
+ | Message starts with | Thrown from | When | Action |
1246
+ | -------------------------------------------------------- | -------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------- |
1247
+ | `[BymaxLoggerModule] options.` | `forRoot` / `forRootAsync`, at module setup | any option fails validation: a missing `service`, a `level` outside the set, a bad type, a list option with more than 10000 entries or a length that is not a count, an option object with more than 256 prototypes | Fix the option the message names |
1248
+ | `LOGGER_BUILTINS_REPLACED` | `forRoot` / `forRootAsync`, and when the logger is built | a built-in the logger reads names with was replaced after the library was loaded | Remove the patch, or apply it before the library is imported |
1249
+ | `[BymaxLoggerModule] options could not be read` | `forRoot` / `forRootAsync`, at module setup | an option the host supplies threw when it was read (a getter or a Proxy trap) | Fix the option; the error the host threw is the `cause` |
1250
+ | `[BymaxLoggerModule] useNestLogger(app) called but` | `BymaxLoggerModule.useNestLogger` | the module was never imported into the application | Import `BymaxLoggerModule` before calling it |
1251
+ | `[BymaxLoggerModule] applyAccessLog(app) called but` | `applyAccessLog` | the module was never imported into the application | Import `BymaxLoggerModule` before calling it |
1252
+ | `[BymaxLoggerModule] useRequestContext(app) called but` | `useRequestContext` | the module was never imported into the application | Import `BymaxLoggerModule` before calling it |
1253
+ | `[LogPerformance] thresholdMs must be` | `@LogPerformance`, at class definition | the threshold is not a finite number of zero or more (a `TypeError`) | Pass a finite number of milliseconds |
1254
+ | `[PrettyDevDestination] pino-pretty is not installed` | `PrettyDevDestination.onInit` | the destination is registered and resolving `pino-pretty` itself fails | Install `pino-pretty` or drop the destination |
1255
+ | `[PrettyDevDestination] pino-pretty failed to start` | `PrettyDevDestination.onInit` | `pino-pretty` is found but importing it or building the transform throws | Read the message and the error's `cause`: it is the real failure |
1256
+ | `[PrettyDevDestination] refused in production` | `PrettyDevDestination.onInit` | `NODE_ENV` is exactly `production` | Use `DefaultStdoutDestination` in production |
1257
+ | `[LogContextService] set() called outside run() scope` | `LogContextService.set` | called with no active `run()` | Wrap the work in `logContext.run({ ... }, () => ...)` |
1258
+ | `[LogContextService] Refusing to set unsafe context key` | `LogContextService.set` | the key is `__proto__`, `constructor` or `prototype` | Use an ordinary key |
1258
1259
 
1259
1260
  The `PrettyDevDestination` errors are thrown inside `onInit`, which the registry contains: the boot continues and the failure is reported as `LOGGER_DESTINATION_INIT_FAILED` below.
1260
1261
 
1261
1262
  ### Log keys
1262
1263
 
1263
- | Code | Surfaces as | When | Action |
1264
- | ------------------------------------ | -------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------- |
1265
- | `LOGGER_DESTINATION_INIT_FAILED` | NDJSON line on `stderr` | `destination.onInit()` throws or rejects, or `destination.onRegistryReady()` throws, rejects or exceeds `destinationHookTimeoutMs` (a destination whose `onInit` succeeded keeps receiving entries) | Sink is removed from the write fan-out and shutdown; boot continues |
1266
- | `LOGGER_DESTINATION_SHUTDOWN_FAILED` | NDJSON line on `stderr` | `destination.onShutdown()` throws, rejects or does not settle within the shutdown budget | The teardown of the other destinations goes on; anything the sink still held is lost |
1267
- | `LOGGER_DESTINATION_WRITE_FAILED` | NDJSON line on `stderr` | `destination.write()` throws or rejects | Entry dropped for that destination; others continue |
1268
- | `HTTP_UNEXPECTED_ERROR_DROPPED` | NDJSON line on `stderr` | `PinoUnexpectedErrorSink` could not log a report (the logger threw, or the report could not be read) | The report is dropped; the line names why. The response is unaffected |
1269
- | `LOGGER_OTEL_API_BROKEN` | NDJSON line on `stderr`, once | `@opentelemetry/api` is installed but throws while loading, or exports no usable `trace` namespace | Reinstall it, or turn `otel.shouldAutoInjectTraceContext` off; until then `traceId` and `spanId` are absent |
1270
- | `LOGGER_BOOTSTRAP_WARNING` | log entry with `reason: 'OTEL_API_UNAVAILABLE'` | `otel.shouldAutoInjectTraceContext` is on and `@opentelemetry/api` cannot be resolved | Install `@opentelemetry/api`, or turn the option off; until then `traceId` and `spanId` are absent |
1271
- | `LOGGER_BOOTSTRAP_WARNING` | log entry (`warn`) with `shouldDisableDefaultRedact: true` and `redactPathCount` | `shouldDisableDefaultRedact` is on | None; the entry exists so a security review can audit it |
1272
- | `LOGGER_ENTRY_TRUNCATED` | `_logKey` in the envelope | a serialized field exceeds `maxEntrySizeBytes` | Reduce the payload or raise the ceiling |
1273
- | `LOGGER_REDACTION_FAILED` | `_logKey` in the envelope, with `_redactionFailed: true` | a record cannot be walked by the redactor (a throwing getter, a hostile proxy in the metadata) | The record is dropped whole, never partly emitted; the message and ambient context stay. Find the value that broke the walk |
1264
+ | Code | Level | Surfaces as | Fields | When | Action |
1265
+ | ------------------------------------ | ----------- | ----------------------------- | --------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- |
1266
+ | `LOGGER_BOOTSTRAP_OK` | `info` | log entry | none of its own | every `onInit` and `onRegistryReady` has settled or timed out, failed or not | None. Written once |
1267
+ | `LOGGER_SHUTDOWN_OK` | `info` | log entry | `destinations` (the number about to be closed) | shutdown starts, before any `onShutdown` | None. Where `info` is written, its absence means the process was killed rather than shut down |
1268
+ | `LOGGER_DESTINATION_INIT_FAILED` | `error` | NDJSON line on `stderr` | `destination`, `err` (`type`, `message`), `msg` | `destination.onInit()` or `destination.onRegistryReady()` throws, rejects or exceeds `destinationHookTimeoutMs` (a destination whose `onInit` succeeded keeps receiving entries) | A sink whose `onInit` failed is removed from the write fan-out and shutdown; boot continues |
1269
+ | `LOGGER_DESTINATION_SHUTDOWN_FAILED` | `error` | NDJSON line on `stderr` | `destination`, `err`, `msg` | `destination.onShutdown()` throws, rejects or does not settle within the shutdown budget | Anything the sink still held is lost |
1270
+ | `LOGGER_DESTINATION_WRITE_FAILED` | `error` | NDJSON line on `stderr` | `destination`, `err`, `msg`, and `suppressed` (failures not reported since the last line) when above zero | `destination.write()` throws or rejects | Entry dropped for that destination; others continue |
1271
+ | `HTTP_UNEXPECTED_ERROR_DROPPED` | `error` | NDJSON line on `stderr` | `destination` (`PinoUnexpectedErrorSink`), `err`, `msg` | `PinoUnexpectedErrorSink` could not log a report (the logger threw, or the report could not be read) | The report is dropped; the line names why. The response is unaffected |
1272
+ | `LOGGER_OTEL_API_BROKEN` | `warn` | NDJSON line on `stderr`, once | `err`, `msg` | `@opentelemetry/api` is installed but unusable | Reinstall it, or turn `otel.shouldAutoInjectTraceContext` off; until then `traceId` and `spanId` are absent |
1273
+ | `LOGGER_BOOTSTRAP_WARNING` | `warn` | log entry | `reason: 'OTEL_API_UNAVAILABLE'`, `shouldAutoInjectTraceContext: true` | `otel.shouldAutoInjectTraceContext` is on and `@opentelemetry/api` cannot be loaded | Install `@opentelemetry/api`, or turn the option off; until then `traceId` and `spanId` are absent |
1274
+ | `LOGGER_BOOTSTRAP_WARNING` | `warn` | log entry | `shouldDisableDefaultRedact: true`, `redactPathCount` | `shouldDisableDefaultRedact` is on | None; the entry exists so a security review can audit it |
1275
+ | `LOGGER_ENTRY_TRUNCATED` | the entry's | `_logKey` in the envelope | `_truncated`, `_originalSize` (`-1` when it could not be measured), `_preview`, in place of the field | a serialized field exceeds `maxEntrySizeBytes` or cannot be measured | Reduce the payload or raise the ceiling |
1276
+ | `LOGGER_REDACTION_FAILED` | the entry's | `_logKey` in the envelope | `_redactionFailed: true` | a record cannot be walked by the redactor (a throwing getter, a hostile proxy in the metadata) | The record is dropped whole, never partly emitted; the message stays. Find the value that broke the walk |
1277
+
1278
+ Some `stderr` reports are plain text, carry no key and start with `[DestinationRegistry]`: a full destination queue (with the entries dropped since the last report), the totals of dropped entries and of failed writes at shutdown, a drain that ended with entries still queued, and the destinations whose `onShutdown` was not called because the shutdown budget was spent.
1274
1279
 
1275
1280
  ---
1276
1281
 
@@ -863,18 +863,15 @@ var I_LIKE = new Map(
863
863
  var I_LIKE_PAIRS = Array.from(I_LIKE);
864
864
  function foldKey(key, keepSeparators = false) {
865
865
  if (keepSeparators) {
866
- if (matchesPattern(PLAIN, key)) return lowerCase(key);
867
- return withLookalikes(
866
+ return matchesPattern(PLAIN, key) ? lowerCase(key) : withLookalikes(
868
867
  dropInvisible(readDots(readGlyphs(lowerCase(normalizeText(key, "NFKD"))), "."), ""),
869
868
  true
870
869
  );
871
870
  }
872
- if (matchesPattern(PLAIN, key)) return lowerCase(dropNotAscii(key, ""));
873
- return withLookalikes(dropNotName(readGlyphs(lowerCase(normalizeText(key, "NFKD"))), ""), true);
871
+ return matchesPattern(PLAIN, key) ? lowerCase(dropNotAscii(key, "")) : withLookalikes(dropNotName(readGlyphs(lowerCase(normalizeText(key, "NFKD"))), ""), true);
874
872
  }
875
873
  function foldStrict(key) {
876
- if (matchesPattern(PLAIN, key)) return lowerCase(dropNotAscii(key, ""));
877
- return withLookalikes(
874
+ return matchesPattern(PLAIN, key) ? lowerCase(dropNotAscii(key, "")) : withLookalikes(
878
875
  dropNotNameStrict(
879
876
  standInSymbols(readGlyphs(lowerCase(normalizeText(key, "NFKD"))), SYMBOL_STAND_IN),
880
877
  ""
@@ -939,10 +936,11 @@ function matchesFolded(names, folded) {
939
936
  const { byLength, longest } = groupsOf(names);
940
937
  if (longest === 0) return false;
941
938
  if (stands > longest) return true;
942
- if (letters.length - stands > longest) return false;
939
+ const shortest = letters.length - stands;
940
+ const reach = longest - shortest;
943
941
  const lengths = Array.from(
944
- { length: wide + stands + 1 },
945
- (_, extra) => byLength.get(letters.length - stands + extra) ?? []
942
+ { length: Math.min(wide + stands + 1, reach + 1) },
943
+ (_, extra) => byLength.get(shortest + extra) ?? []
946
944
  );
947
945
  if (lengths.reduce((count, same) => count + same.length, 0) > MAX_CANDIDATES) return true;
948
946
  return lengths.some((same) => same.some((name) => matchesName(letters, [...name])));
@@ -989,7 +987,8 @@ function matchesKey(names, key) {
989
987
  // src/server/utils/hide-message-in-stack.util.ts
990
988
  function failureTable(message) {
991
989
  const table = new Int32Array(message.length);
992
- for (let i = 1, matched = 0; i < message.length; i += 1) {
990
+ const end = Math.max(1, message.length);
991
+ for (let i = 1, matched = 0; i !== end; i += 1) {
993
992
  while (matched > 0 && message[i] !== message[matched]) matched = table[matched - 1];
994
993
  if (message[i] === message[matched]) matched += 1;
995
994
  table[i] = matched;
@@ -997,14 +996,14 @@ function failureTable(message) {
997
996
  return table;
998
997
  }
999
998
  function occurrences(stack, message) {
1000
- if (message.length > stack.length) return [];
1001
- const table = failureTable(message);
999
+ const searched = message.slice(0, stack.length + 1);
1000
+ const table = failureTable(searched);
1002
1001
  const spans = [];
1003
- for (let i = 0, matched = 0; i < stack.length; i += 1) {
1004
- while (matched > 0 && stack[i] !== message[matched]) matched = table[matched - 1];
1005
- if (stack[i] === message[matched]) matched += 1;
1006
- if (matched === message.length) {
1007
- const start = i + 1 - message.length;
1002
+ for (let i = 0, matched = 0; i !== stack.length; i += 1) {
1003
+ while (matched > 0 && stack[i] !== searched[matched]) matched = table[matched - 1];
1004
+ if (stack[i] === searched[matched]) matched += 1;
1005
+ if (matched === searched.length) {
1006
+ const start = i + 1 - searched.length;
1008
1007
  const last = spans[spans.length - 1];
1009
1008
  if (last !== void 0 && start < last[1]) last[1] = i + 1;
1010
1009
  else spans.push([start, i + 1]);
@@ -1254,7 +1253,7 @@ function readOptional(read, node) {
1254
1253
  }
1255
1254
  }
1256
1255
  function toSanitizedChild(value, seen, depth2, walk2) {
1257
- if (isObject(value) && seen.has(value)) {
1256
+ if (seen.has(value)) {
1258
1257
  return CIRCULAR_SENTINEL;
1259
1258
  }
1260
1259
  return toSanitizedError(value, seen, depth2, walk2);
@@ -1319,9 +1318,6 @@ function scrubStack(stack, header, wasLonger = false) {
1319
1318
  );
1320
1319
  return cutText(scrubbed, wasLonger || stack.length > MAX_STACK_SCAN);
1321
1320
  }
1322
- function isObject(value) {
1323
- return typeof value === "object" && value !== null;
1324
- }
1325
1321
  function createDepthMarker() {
1326
1322
  return { _truncated: true, _reason: "cause-depth-exceeded" };
1327
1323
  }
@@ -1432,7 +1428,7 @@ function rulesBelow(rules, key, value, honorToJson) {
1432
1428
  if (leavesErrorText(rules, key, value, honorToJson)) {
1433
1429
  return { ...rules, exemptKeys: ERROR_TEXT_KEYS };
1434
1430
  }
1435
- return rules.exemptKeys === void 0 && rules.headerKept !== true ? rules : { ...rules, exemptKeys: void 0, headerKept: void 0 };
1431
+ return { ...rules, exemptKeys: void 0, headerKept: void 0 };
1436
1432
  }
1437
1433
  function isCensored(rules, key, value) {
1438
1434
  return matchesKey(rules.sensitive, key) && !(typeof value === "string" && rules.exemptKeys?.has(key));
@@ -2104,8 +2100,7 @@ function hasTokenPart(segment) {
2104
2100
  }
2105
2101
  function withoutExtension(segment) {
2106
2102
  const dot = segment.lastIndexOf(".");
2107
- const dotAfterStart = dot > 0;
2108
- return dotAfterStart && segment.length - dot <= 9 ? segment.slice(0, dot) : segment;
2103
+ return segment.length - dot <= 9 ? segment.slice(0, dot) : segment;
2109
2104
  }
2110
2105
  function looksLikeToken(value) {
2111
2106
  return HEX_SECRET_REGEX.test(value) || HEX_RUN_REGEX.test(value) || JWT_SECRET_REGEX.test(value) || TOKEN_SECRET_REGEX.test(value) && !SLUG_REGEX.test(value) && !UUID_SEGMENT_REGEX.test(value);
@@ -3181,9 +3176,7 @@ function createTraceContextMixin(logContext, opts) {
3181
3176
  return function mixin(_mergeObject, _level, _logger) {
3182
3177
  const merged = {};
3183
3178
  const store = logContext.getStore();
3184
- if (store) {
3185
- Object.assign(merged, store);
3186
- }
3179
+ Object.assign(merged, store);
3187
3180
  if (traceApi) {
3188
3181
  try {
3189
3182
  const span = traceApi.getActiveSpan();
@@ -3258,8 +3251,7 @@ function rescueToStdout(payload) {
3258
3251
  function ownQueuedBytes(destination) {
3259
3252
  try {
3260
3253
  const bytes = destination.queuedBytes?.() ?? 0;
3261
- const positive = Number.isFinite(bytes) && bytes > 0;
3262
- return positive ? bytes : 0;
3254
+ return Number.isFinite(bytes) ? Math.max(0, bytes) : 0;
3263
3255
  } catch {
3264
3256
  return 0;
3265
3257
  }
@@ -3331,7 +3323,6 @@ function destinationToStream(destination, health, maxQueueBytes = 0, censorMessa
3331
3323
  // Keep string chunks as strings (Node's default re-encodes them to Buffers
3332
3324
  // before `_write`): the common Pino path emits NDJSON strings, so this skips
3333
3325
  // a string→Buffer→string round-trip on the hot logging path.
3334
- // Stryker disable next-line BooleanLiteral: equivalent for every chunk this stream receives — with `true`, Node encodes the string to a Buffer and `write()` below decodes it back with `toString('utf-8')`. Pino writes UTF-8 NDJSON strings at the default encoding, so the round-trip returns the identical string. It is NOT equivalent in general: a `write(chunk, 'latin1')` would round-trip through UTF-8 and change non-ASCII bytes, which is unreachable here because nothing writes to this stream but Pino. The flag stays because it skips the round-trip on the hot logging path.
3335
3326
  decodeStrings: false,
3336
3327
  write(chunk, _encoding, settled) {
3337
3328
  const bytes = Buffer.byteLength(chunk);
@@ -3839,16 +3830,16 @@ function withSemconvException(record, format, maxBytes = Number.POSITIVE_INFINIT
3839
3830
  }
3840
3831
 
3841
3832
  // src/server/utils/serialize-request.util.ts
3842
- function isObject2(value) {
3833
+ function isObject(value) {
3843
3834
  return typeof value === "object" && value !== null;
3844
3835
  }
3845
3836
  function isRequest(value) {
3846
- if (!isObject2(value)) return false;
3837
+ if (!isObject(value)) return false;
3847
3838
  const { rawHeaders, method, socket } = value;
3848
- return Array.isArray(rawHeaders) || typeof method === "string" && isObject2(socket);
3839
+ return Array.isArray(rawHeaders) || typeof method === "string" && isObject(socket);
3849
3840
  }
3850
3841
  function copyHeaders(headers) {
3851
- return isObject2(headers) ? { ...headers } : {};
3842
+ return isObject(headers) ? { ...headers } : {};
3852
3843
  }
3853
3844
  function serializeRequestValue(input, secretSegments = []) {
3854
3845
  try {
@@ -4617,7 +4608,9 @@ var DestinationRegistry = class {
4617
4608
  if (configured === void 0) {
4618
4609
  return this.options.level;
4619
4610
  }
4620
- return LOG_LEVEL_PRIORITY.indexOf(configured) > LOG_LEVEL_PRIORITY.indexOf(this.options.level) ? configured : this.options.level;
4611
+ return LOG_LEVEL_PRIORITY.slice(LOG_LEVEL_PRIORITY.indexOf(this.options.level)).includes(
4612
+ configured
4613
+ ) ? configured : this.options.level;
4621
4614
  }
4622
4615
  /**
4623
4616
  * Report one destination init failure as a structured
@@ -5547,8 +5540,8 @@ function isRecord3(value) {
5547
5540
  }
5548
5541
  function exceptionFields(error) {
5549
5542
  try {
5550
- if (!isRecord3(error) || typeof error["getResponse"] !== "function") return {};
5551
- const response = error["getResponse"]();
5543
+ if (!isRecord3(error)) return {};
5544
+ const response = error["getResponse"]?.();
5552
5545
  if (!isRecord3(response)) return {};
5553
5546
  const nested = response["error"];
5554
5547
  const carrier = isRecord3(nested) && typeof nested["code"] === "string" ? nested : response;
@@ -163,10 +163,10 @@ interface ILogDestination {
163
163
  * - Return a Promise for async I/O
164
164
  *
165
165
  * Errors thrown here, and rejections of a returned promise, are caught by the
166
- * library: the entry is dropped for this destination only, and one failure line
167
- * is written to stderr per failed entry. There is no retry and no circuit
168
- * breaker, so a destination that initialized and keeps failing keeps receiving
169
- * entries and keeps being reported; one that needs to back off does so itself.
166
+ * library: the entry is dropped for this destination only. Failure lines on stderr
167
+ * are throttled to one a window for each destination, and shutdown writes the total when more than one write failed. There is no
168
+ * retry and no circuit breaker, so a destination that initialized and keeps failing keeps
169
+ * receiving entries; one that needs to back off does so itself.
170
170
  * (A destination whose `onInit()` failed is a different case: it receives no
171
171
  * entries at all.)
172
172
  *
@@ -235,8 +235,8 @@ interface ILogDestination {
235
235
  * Optional lifecycle hook — called during NestJS `onApplicationShutdown`.
236
236
  * MUST flush any pending writes and close resources.
237
237
  *
238
- * The library awaits this — graceful shutdown blocks until all destinations
239
- * return.
238
+ * The library awaits this within the shutdown budget (`shutdown.timeoutMs`): a hook that has
239
+ * not settled when the budget ends is reported and left, and the hooks not yet called are skipped.
240
240
  */
241
241
  onShutdown?(): void | PromiseLike<void>;
242
242
  }
@@ -163,10 +163,10 @@ interface ILogDestination {
163
163
  * - Return a Promise for async I/O
164
164
  *
165
165
  * Errors thrown here, and rejections of a returned promise, are caught by the
166
- * library: the entry is dropped for this destination only, and one failure line
167
- * is written to stderr per failed entry. There is no retry and no circuit
168
- * breaker, so a destination that initialized and keeps failing keeps receiving
169
- * entries and keeps being reported; one that needs to back off does so itself.
166
+ * library: the entry is dropped for this destination only. Failure lines on stderr
167
+ * are throttled to one a window for each destination, and shutdown writes the total when more than one write failed. There is no
168
+ * retry and no circuit breaker, so a destination that initialized and keeps failing keeps
169
+ * receiving entries; one that needs to back off does so itself.
170
170
  * (A destination whose `onInit()` failed is a different case: it receives no
171
171
  * entries at all.)
172
172
  *
@@ -235,8 +235,8 @@ interface ILogDestination {
235
235
  * Optional lifecycle hook — called during NestJS `onApplicationShutdown`.
236
236
  * MUST flush any pending writes and close resources.
237
237
  *
238
- * The library awaits this — graceful shutdown blocks until all destinations
239
- * return.
238
+ * The library awaits this within the shutdown budget (`shutdown.timeoutMs`): a hook that has
239
+ * not settled when the budget ends is reported and left, and the hooks not yet called are skipped.
240
240
  */
241
241
  onShutdown?(): void | PromiseLike<void>;
242
242
  }
@@ -860,18 +860,15 @@ var I_LIKE = new Map(
860
860
  var I_LIKE_PAIRS = Array.from(I_LIKE);
861
861
  function foldKey(key, keepSeparators = false) {
862
862
  if (keepSeparators) {
863
- if (matchesPattern(PLAIN, key)) return lowerCase(key);
864
- return withLookalikes(
863
+ return matchesPattern(PLAIN, key) ? lowerCase(key) : withLookalikes(
865
864
  dropInvisible(readDots(readGlyphs(lowerCase(normalizeText(key, "NFKD"))), "."), ""),
866
865
  true
867
866
  );
868
867
  }
869
- if (matchesPattern(PLAIN, key)) return lowerCase(dropNotAscii(key, ""));
870
- return withLookalikes(dropNotName(readGlyphs(lowerCase(normalizeText(key, "NFKD"))), ""), true);
868
+ return matchesPattern(PLAIN, key) ? lowerCase(dropNotAscii(key, "")) : withLookalikes(dropNotName(readGlyphs(lowerCase(normalizeText(key, "NFKD"))), ""), true);
871
869
  }
872
870
  function foldStrict(key) {
873
- if (matchesPattern(PLAIN, key)) return lowerCase(dropNotAscii(key, ""));
874
- return withLookalikes(
871
+ return matchesPattern(PLAIN, key) ? lowerCase(dropNotAscii(key, "")) : withLookalikes(
875
872
  dropNotNameStrict(
876
873
  standInSymbols(readGlyphs(lowerCase(normalizeText(key, "NFKD"))), SYMBOL_STAND_IN),
877
874
  ""
@@ -936,10 +933,11 @@ function matchesFolded(names, folded) {
936
933
  const { byLength, longest } = groupsOf(names);
937
934
  if (longest === 0) return false;
938
935
  if (stands > longest) return true;
939
- if (letters.length - stands > longest) return false;
936
+ const shortest = letters.length - stands;
937
+ const reach = longest - shortest;
940
938
  const lengths = Array.from(
941
- { length: wide + stands + 1 },
942
- (_, extra) => byLength.get(letters.length - stands + extra) ?? []
939
+ { length: Math.min(wide + stands + 1, reach + 1) },
940
+ (_, extra) => byLength.get(shortest + extra) ?? []
943
941
  );
944
942
  if (lengths.reduce((count, same) => count + same.length, 0) > MAX_CANDIDATES) return true;
945
943
  return lengths.some((same) => same.some((name) => matchesName(letters, [...name])));
@@ -986,7 +984,8 @@ function matchesKey(names, key) {
986
984
  // src/server/utils/hide-message-in-stack.util.ts
987
985
  function failureTable(message) {
988
986
  const table = new Int32Array(message.length);
989
- for (let i = 1, matched = 0; i < message.length; i += 1) {
987
+ const end = Math.max(1, message.length);
988
+ for (let i = 1, matched = 0; i !== end; i += 1) {
990
989
  while (matched > 0 && message[i] !== message[matched]) matched = table[matched - 1];
991
990
  if (message[i] === message[matched]) matched += 1;
992
991
  table[i] = matched;
@@ -994,14 +993,14 @@ function failureTable(message) {
994
993
  return table;
995
994
  }
996
995
  function occurrences(stack, message) {
997
- if (message.length > stack.length) return [];
998
- const table = failureTable(message);
996
+ const searched = message.slice(0, stack.length + 1);
997
+ const table = failureTable(searched);
999
998
  const spans = [];
1000
- for (let i = 0, matched = 0; i < stack.length; i += 1) {
1001
- while (matched > 0 && stack[i] !== message[matched]) matched = table[matched - 1];
1002
- if (stack[i] === message[matched]) matched += 1;
1003
- if (matched === message.length) {
1004
- const start = i + 1 - message.length;
999
+ for (let i = 0, matched = 0; i !== stack.length; i += 1) {
1000
+ while (matched > 0 && stack[i] !== searched[matched]) matched = table[matched - 1];
1001
+ if (stack[i] === searched[matched]) matched += 1;
1002
+ if (matched === searched.length) {
1003
+ const start = i + 1 - searched.length;
1005
1004
  const last = spans[spans.length - 1];
1006
1005
  if (last !== void 0 && start < last[1]) last[1] = i + 1;
1007
1006
  else spans.push([start, i + 1]);
@@ -1251,7 +1250,7 @@ function readOptional(read, node) {
1251
1250
  }
1252
1251
  }
1253
1252
  function toSanitizedChild(value, seen, depth2, walk2) {
1254
- if (isObject(value) && seen.has(value)) {
1253
+ if (seen.has(value)) {
1255
1254
  return CIRCULAR_SENTINEL;
1256
1255
  }
1257
1256
  return toSanitizedError(value, seen, depth2, walk2);
@@ -1316,9 +1315,6 @@ function scrubStack(stack, header, wasLonger = false) {
1316
1315
  );
1317
1316
  return cutText(scrubbed, wasLonger || stack.length > MAX_STACK_SCAN);
1318
1317
  }
1319
- function isObject(value) {
1320
- return typeof value === "object" && value !== null;
1321
- }
1322
1318
  function createDepthMarker() {
1323
1319
  return { _truncated: true, _reason: "cause-depth-exceeded" };
1324
1320
  }
@@ -1429,7 +1425,7 @@ function rulesBelow(rules, key, value, honorToJson) {
1429
1425
  if (leavesErrorText(rules, key, value, honorToJson)) {
1430
1426
  return { ...rules, exemptKeys: ERROR_TEXT_KEYS };
1431
1427
  }
1432
- return rules.exemptKeys === void 0 && rules.headerKept !== true ? rules : { ...rules, exemptKeys: void 0, headerKept: void 0 };
1428
+ return { ...rules, exemptKeys: void 0, headerKept: void 0 };
1433
1429
  }
1434
1430
  function isCensored(rules, key, value) {
1435
1431
  return matchesKey(rules.sensitive, key) && !(typeof value === "string" && rules.exemptKeys?.has(key));
@@ -2101,8 +2097,7 @@ function hasTokenPart(segment) {
2101
2097
  }
2102
2098
  function withoutExtension(segment) {
2103
2099
  const dot = segment.lastIndexOf(".");
2104
- const dotAfterStart = dot > 0;
2105
- return dotAfterStart && segment.length - dot <= 9 ? segment.slice(0, dot) : segment;
2100
+ return segment.length - dot <= 9 ? segment.slice(0, dot) : segment;
2106
2101
  }
2107
2102
  function looksLikeToken(value) {
2108
2103
  return HEX_SECRET_REGEX.test(value) || HEX_RUN_REGEX.test(value) || JWT_SECRET_REGEX.test(value) || TOKEN_SECRET_REGEX.test(value) && !SLUG_REGEX.test(value) && !UUID_SEGMENT_REGEX.test(value);
@@ -3178,9 +3173,7 @@ function createTraceContextMixin(logContext, opts) {
3178
3173
  return function mixin(_mergeObject, _level, _logger) {
3179
3174
  const merged = {};
3180
3175
  const store = logContext.getStore();
3181
- if (store) {
3182
- Object.assign(merged, store);
3183
- }
3176
+ Object.assign(merged, store);
3184
3177
  if (traceApi) {
3185
3178
  try {
3186
3179
  const span = traceApi.getActiveSpan();
@@ -3255,8 +3248,7 @@ function rescueToStdout(payload) {
3255
3248
  function ownQueuedBytes(destination) {
3256
3249
  try {
3257
3250
  const bytes = destination.queuedBytes?.() ?? 0;
3258
- const positive = Number.isFinite(bytes) && bytes > 0;
3259
- return positive ? bytes : 0;
3251
+ return Number.isFinite(bytes) ? Math.max(0, bytes) : 0;
3260
3252
  } catch {
3261
3253
  return 0;
3262
3254
  }
@@ -3328,7 +3320,6 @@ function destinationToStream(destination, health, maxQueueBytes = 0, censorMessa
3328
3320
  // Keep string chunks as strings (Node's default re-encodes them to Buffers
3329
3321
  // before `_write`): the common Pino path emits NDJSON strings, so this skips
3330
3322
  // a string→Buffer→string round-trip on the hot logging path.
3331
- // Stryker disable next-line BooleanLiteral: equivalent for every chunk this stream receives — with `true`, Node encodes the string to a Buffer and `write()` below decodes it back with `toString('utf-8')`. Pino writes UTF-8 NDJSON strings at the default encoding, so the round-trip returns the identical string. It is NOT equivalent in general: a `write(chunk, 'latin1')` would round-trip through UTF-8 and change non-ASCII bytes, which is unreachable here because nothing writes to this stream but Pino. The flag stays because it skips the round-trip on the hot logging path.
3332
3323
  decodeStrings: false,
3333
3324
  write(chunk, _encoding, settled) {
3334
3325
  const bytes = Buffer.byteLength(chunk);
@@ -3836,16 +3827,16 @@ function withSemconvException(record, format, maxBytes = Number.POSITIVE_INFINIT
3836
3827
  }
3837
3828
 
3838
3829
  // src/server/utils/serialize-request.util.ts
3839
- function isObject2(value) {
3830
+ function isObject(value) {
3840
3831
  return typeof value === "object" && value !== null;
3841
3832
  }
3842
3833
  function isRequest(value) {
3843
- if (!isObject2(value)) return false;
3834
+ if (!isObject(value)) return false;
3844
3835
  const { rawHeaders, method, socket } = value;
3845
- return Array.isArray(rawHeaders) || typeof method === "string" && isObject2(socket);
3836
+ return Array.isArray(rawHeaders) || typeof method === "string" && isObject(socket);
3846
3837
  }
3847
3838
  function copyHeaders(headers) {
3848
- return isObject2(headers) ? { ...headers } : {};
3839
+ return isObject(headers) ? { ...headers } : {};
3849
3840
  }
3850
3841
  function serializeRequestValue(input, secretSegments = []) {
3851
3842
  try {
@@ -4614,7 +4605,9 @@ var DestinationRegistry = class {
4614
4605
  if (configured === void 0) {
4615
4606
  return this.options.level;
4616
4607
  }
4617
- return LOG_LEVEL_PRIORITY.indexOf(configured) > LOG_LEVEL_PRIORITY.indexOf(this.options.level) ? configured : this.options.level;
4608
+ return LOG_LEVEL_PRIORITY.slice(LOG_LEVEL_PRIORITY.indexOf(this.options.level)).includes(
4609
+ configured
4610
+ ) ? configured : this.options.level;
4618
4611
  }
4619
4612
  /**
4620
4613
  * Report one destination init failure as a structured
@@ -5544,8 +5537,8 @@ function isRecord3(value) {
5544
5537
  }
5545
5538
  function exceptionFields(error) {
5546
5539
  try {
5547
- if (!isRecord3(error) || typeof error["getResponse"] !== "function") return {};
5548
- const response = error["getResponse"]();
5540
+ if (!isRecord3(error)) return {};
5541
+ const response = error["getResponse"]?.();
5549
5542
  if (!isRecord3(response)) return {};
5550
5543
  const nested = response["error"];
5551
5544
  const carrier = isRecord3(nested) && typeof nested["code"] === "string" ? nested : response;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bymax-one/nest-logger",
3
- "version": "1.4.30",
3
+ "version": "1.4.32",
4
4
  "description": "Structured JSON logging for NestJS based on Pino 10, with optional OpenTelemetry correlation.",
5
5
  "author": "Bymax One <support@bymax.one>",
6
6
  "license": "MIT",
@@ -81,7 +81,7 @@
81
81
  "check:suppressions": "node scripts/check-suppressions-baseline.mjs",
82
82
  "clean": "rm -rf dist coverage",
83
83
  "check:socket-gate": "node scripts/check-socket-gate.mjs",
84
- "lint": "eslint src scripts test bench '*.config.ts' '*.config.mjs' '*.config.cjs' && pnpm check:socket-gate && pnpm check:spec-headers && node --test scripts/check-spec-headers.test.mjs && node --test scripts/check-suppressions-baseline.test.mjs && pnpm check:property-path && node --test scripts/check-have-property-path.test.mjs && node --test scripts/generate-glyph-letters.test.mjs",
84
+ "lint": "eslint src scripts test bench '*.config.ts' '*.config.mjs' '*.config.cjs' && pnpm check:socket-gate && pnpm check:spec-headers && node --test scripts/check-spec-headers.test.mjs && node --test scripts/check-suppressions-baseline.test.mjs && pnpm check:property-path && node --test scripts/check-have-property-path.test.mjs && node --test scripts/check-dist-fresh.test.mjs && node --test scripts/generate-glyph-letters.test.mjs",
85
85
  "lint:fix": "eslint src scripts test bench '*.config.ts' '*.config.mjs' '*.config.cjs' --fix",
86
86
  "mutation": "stryker run",
87
87
  "mutation:full": "node -e \"require('node:fs').rmSync('reports/stryker-incremental.json',{force:true,recursive:true})\" && stryker run",
@@ -89,7 +89,7 @@
89
89
  "prepare": "husky",
90
90
  "prepublishOnly": "pnpm clean && pnpm typecheck && pnpm lint && pnpm check:mutants && pnpm check:docs && pnpm test:cov:all && pnpm build && pnpm check:published",
91
91
  "release": "npm publish --provenance --access public",
92
- "size": "node scripts/check-size.mjs",
92
+ "size": "node scripts/check-dist-fresh.mjs && node scripts/check-size.mjs",
93
93
  "test": "jest",
94
94
  "test:all": "pnpm test && pnpm test:e2e",
95
95
  "test:cov": "jest --coverage",
@@ -158,6 +158,7 @@
158
158
  "eslint-plugin-import": "^2.32.0",
159
159
  "eslint-plugin-prettier": "^5.5.5",
160
160
  "eslint-plugin-security": "^4.0.0",
161
+ "express": "^5.2.1",
161
162
  "globals": "^17.6.0",
162
163
  "husky": "^9.1.7",
163
164
  "jest": "^30.4.2",