@bymax-one/nest-logger 1.4.33 → 1.4.35

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,32 @@ heading here.
12
12
 
13
13
  ## [Unreleased]
14
14
 
15
+ ## [1.4.35] - 2026-11-27
16
+
17
+ ### Breaking
18
+
19
+ - **Behaviour change under `redactStrategy: 'names'`:** the `bindings` formatter and the serializers receive a redacted copy of the bindings instead of your objects. In the copy a `Date` arrives as a string, a `Map` as `{}` and a class instance can arrive as a plain object, so a callback that calls a method of one of these can throw. A value in bindings of the raw logger is written as `service.child()` writes it. Migration: have the callback read the copy (a `Date` is an ISO string), or compute the value before you pass it, for example `raw.child({ at: at.getTime() })`. `redactStrategy: 'paths'` keeps your objects, but bindings are then not redacted by name.
20
+
21
+ ### Security
22
+
23
+ - **Under the default `redactStrategy: 'names'`, bindings passed to `child()` and `setBindings()` on the raw logger are now redacted.** Under both strategies, so is what the `serializers`, `formatters.log` and `formatters.level` of child options return.
24
+ - Under `redactStrategy: 'paths'`, bindings of the raw logger are handled as before: Pino's redact paths apply, and your own objects reach the formatters and serializers.
25
+
26
+ ### Documentation
27
+
28
+ - **The message text is not redacted by name**: a value the raw logger formats into it is not walked. The `redact` and `msgPrefix` options of a child are applied as you set them.
29
+
30
+ ## [1.4.34] - 2026-11-27
31
+
32
+ No behaviour change: the published JavaScript is byte-identical to `1.4.33`, and the type declarations differ in comments only.
33
+
34
+ ### Documentation
35
+
36
+ - **The redaction warning shows a call that writes the entry.** Its example used `log()`, which takes Nest's arguments and drops the message, the user id and the metadata of that call; it now uses `info()`.
37
+ - **The redaction engine is named `@pinojs/redact`**, which is what Pino depends on from `10.1.0`, in the README and the doc comments. Two comments that gave a behaviour of the engine it does not have are removed: that duplicate paths throw, and that wildcards stop at bracket-syntax keys.
38
+ - **The README paragraph on how field names are compared reads as one rule again**: it carried the clause about letters that are not ASCII twice, spliced together.
39
+ - **`maxStringLength` and `shutdown` no longer claim more than they do**, in the README and the type declarations: not every string of a record is cut, the text of an object written as the fields of an entry is, and a destination that failed to initialize gets no `onShutdown`.
40
+
15
41
  ## [1.4.33] - 2026-11-27
16
42
 
17
43
  No behaviour change: the published code differs from `1.4.32` in one comment.
@@ -3595,7 +3621,9 @@ published `dist/` is identical — no runtime behaviour changes for consumers.
3595
3621
  - Professional CI suite: `ci.yml`, `bench.yml`, `codeql.yml`, `scorecard.yml`,
3596
3622
  `release.yml`, Dependabot, and issue templates
3597
3623
 
3598
- [Unreleased]: https://github.com/bymaxone/nest-logger/compare/v1.4.33...HEAD
3624
+ [Unreleased]: https://github.com/bymaxone/nest-logger/compare/v1.4.35...HEAD
3625
+ [1.4.35]: https://github.com/bymaxone/nest-logger/compare/v1.4.34...v1.4.35
3626
+ [1.4.34]: https://github.com/bymaxone/nest-logger/compare/v1.4.33...v1.4.34
3599
3627
  [1.4.33]: https://github.com/bymaxone/nest-logger/compare/v1.4.32...v1.4.33
3600
3628
  [1.4.32]: https://github.com/bymaxone/nest-logger/compare/v1.4.31...v1.4.32
3601
3629
  [1.4.31]: https://github.com/bymaxone/nest-logger/compare/v1.4.30...v1.4.31
package/README.md CHANGED
@@ -271,12 +271,12 @@ A key that holds `undefined` or `null` is read as not set, in the options and in
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
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
- | `redactStrategy` | `'names' \| 'paths'` | `'names'` | Engine behind the DEFAULT set. `'paths'` is the legacy `fast-redact` expansion (four-level ceiling, much slower) |
274
+ | `redactPaths` | `string[]` | `[]` | Additional `@pinojs/redact` paths (each at most 256 characters), applied on top of the default coverage |
275
+ | `redactStrategy` | `'names' \| 'paths'` | `'names'` | Engine behind the DEFAULT set. `'paths'` is the legacy `@pinojs/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 |
278
278
  | `maxEntrySizeBytes` | `number` | `65536` | UTF-8 byte ceiling per serialized field, a whole number from 1 to 2147483647 (`err` + any custom serializer); over it the value becomes a truncation envelope |
279
- | `maxStringLength` | `number` | unset (a string is written whole) | The most characters a string of a log record is written with: an integer from 64 to 2147483647. A longer string is cut to that length and ends with `…[truncated]`. See [Bounded string length](#bounded-string-length) |
279
+ | `maxStringLength` | `number` | unset (a string is written whole) | A cut for long string values, an integer from 64 to 2147483647; a value it cuts ends with `…[truncated]`. Not every string is cut (`err` is not): see [Bounded string length](#bounded-string-length) |
280
280
  | `destinationHookTimeoutMs` | `number` | `10000` | Longest `onInit` or `onRegistryReady` of a destination, in ms (an integer from 1 to 2147483647). An `onInit` that does not settle in time counts as one that threw: the destination is failed, skipped and reported, and stays inactive if the call settles later. A hung `onInit` may leak what it opened |
281
281
  | `errorOwnFields` | `'all' \| 'safe'` | `'all'` | Which own fields of an error are written. `'all'` writes every one; `'safe'` writes an allow-list of operational names plus `errorOwnFieldNames` (see [Error fields](#error-fields)). A binary value is written as its size in both. Recommended: `'safe'` |
282
282
  | `errorOwnFieldNames` | `readonly string[]` | `[]` | Own-field names `'safe'` writes beside its default list, matched exactly; ignored under `'all'` |
@@ -302,7 +302,7 @@ A key that holds `undefined` or `null` is read as not set, in the options and in
302
302
 
303
303
  - Every option is type-checked at startup: a wrong type (the string `'false'` for a boolean, say) throws `[BymaxLoggerModule] options.<path> …` and names what was received by type, never by value.
304
304
  - `service.name` and `service.version` must be strings that are not blank after `trim()`.
305
- - `redactPaths` entries must be non-empty strings in `fast-redact` path syntax. A malformed path (`a..b`, `a[`) is not checked by the module: Pino refuses it while the logger is built, with `Invalid redaction path (<path>)`, which is not prefixed `[BymaxLoggerModule]`.
305
+ - `redactPaths` entries must be non-empty strings in `@pinojs/redact` path syntax. That is the engine Pino ships from `10.1.0`; `10.0.0` ships `slow-redact` in its place. A malformed path (`a..b`, `a[`) is not checked by the module: Pino refuses it while the logger is built, with an error that is not prefixed `[BymaxLoggerModule]`.
306
306
  - Each `destinations` entry must be an object with a non-empty string `name` and a `write` function; `onInit`, `onShutdown` and `onRegistryReady`, when present, must be functions. Anything else is refused at startup with `[BymaxLoggerModule] options.destinations[i] …`.
307
307
  - `serializers` must be a plain object whose every value is a function; a key `err` replaces the default `err` serializer.
308
308
  - `http.excludePaths` replaces the default list instead of adding to it, and the defaults are exact anchored paths: `[/^\/health$/]` stops excluding `/metrics`.
@@ -323,7 +323,7 @@ A key that holds `undefined` or `null` is read as not set, in the options and in
323
323
 
324
324
  ### `shutdown` options
325
325
 
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.
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, in reverse registration order, the `onShutdown` of each destination that did not fail to initialize. 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
328
  | Option | Type | Default | Description |
329
329
  | ------------------------- | -------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
@@ -881,13 +881,13 @@ The library censors **62 sensitive field names** wherever they appear in a recor
881
881
  | Other spellings | `access_token`, `refresh_token`, `id_token`, `api_key`, `apikey`, `api_secret`, `client_secret`, `signing_secret`, `private_key`, `secret_key`, `secretKey`, `access-token`, `refresh-token`, `id-token`, `api-key`, `client-secret`, `private-key`, `proxy-authorization`, `session_token`, `sessionToken`, `sessiontoken`, `session-token`, `x-csrf-token`, `x-xsrf-token`, `csrf_token`, `csrfToken`, `csrf-token`, `password_hash`, `new_password`, `old_password` |
882
882
  | HTTP headers (absolute) | `req.headers.authorization`, `req.headers.cookie`, `req.headers["x-api-key"]`, `req.headers["x-auth-token"]`, `res.headers["set-cookie"]` — retained for the legacy `'paths'` strategy; the by-name row above already covers these shapes and every other |
883
883
 
884
- Redaction is one **recursive, snapshotting walk**: a value is censored when its key name is in the set, wherever it sits. A name and a key are compared in one folded form: the case, every character that is not a letter or a digit (the separators `_`, `.` and `-` and every other dash, mark and punctuation), white space, control and zero-width characters, combining marks, the compatibility forms Unicode defines, the negative circled and squared letters and the regional indicators (read as their Latin letter), a symbol that is not ASCII and is no letter (read as a character that stands for nothing, one or two characters of a name) and a list of letters drawn like a Latin one are read through, and a letter that is not ASCII and that the list does not read as one Latin letter stands for one or two letters (in a key no longer than the longest name; a key longer than every name is never taken for one, so a field of another script is hidden when it is short, which is the price of never letting a spelling of a name through, and kept when it is long), so a key that has one is hidden by a name it matches everywhere else; the keys the entry owns are compared exactly after folding, so a caller field is never dropped for looking like one, so a key that has one is hidden by a name of a compatible length that matches it everywhere else (`autһorization` is hidden by `authorization`, and a key of the same length that only shares its ASCII letters is hidden too), so `apiKey` also hides `api_key`, `API-KEY`, `api\u200bKey` and `\u0430piKey`, and a name hides the field however an untrusted payload spells it. A `redactPaths` entry is at most 256 characters (a longer one is refused at startup by option name, without its value). A key that spells a configured name another way is the same name, so a field whose name only differs in those ways is hidden too. Under `redactStrategy: 'paths'` the paths are matched exactly by `fast-redact`: literally, with no folding of case, separators or look-alikes, and none of this applies. Nothing the caller passed is mutated, and every value is read once and pinned into a fresh structure, so what reaches the sink is what was inspected even when the payload carries accessors or a `toJSON` that could answer differently on a second read. A value with a `toJSON` is inspected through that method's output; when the source object itself carries a sensitive key, the method is not trusted and the whole value is censored, because a method could rename what it exposes. `DEFAULT_REDACT_PATHS` is still exported at full fidelity, and `redactStrategy: 'paths'` feeds it to `fast-redact` for anyone depending on exact path semantics, with a four-level ceiling and a much higher cost.
884
+ Redaction is one **recursive, snapshotting walk**: a value is censored when its key name is in the set, wherever it sits. A name and a key are compared in one folded form: the case, every character that is not a letter or a digit (the separators `_`, `.` and `-` and every other dash, mark and punctuation), white space, control and zero-width characters, combining marks, the compatibility forms Unicode defines, the negative circled and squared letters and the regional indicators (read as their Latin letter), a symbol that is not ASCII and is no letter or currency sign (read as a character that stands for nothing, one or two characters of a name) and a list of letters drawn like a Latin one are read through, so `apiKey` also hides `api_key`, `API-KEY`, `api\u200bKey` and `\u0430piKey`. A letter that is not ASCII and that the list does not read as one Latin letter can stand for one or two characters of a name, so a key that has one may be hidden although it does not spell that name (`autһorization` is hidden by `authorization`). The keys the entry owns are compared exactly after folding, so a caller field is never dropped for a letter the folding does not read. A key that spells a configured name another way is the same name, so a field whose name only differs in those ways is hidden too. A `redactPaths` entry is at most 256 characters (a longer one is refused at startup by option name, without its value). Under `redactStrategy: 'paths'` the paths are matched exactly by `@pinojs/redact`: literally, with no folding of case, separators or look-alikes. Nothing the caller passed is mutated, and every value is read once and pinned into a fresh structure, so what reaches the sink is what was inspected even when the payload carries accessors or a `toJSON` that could answer differently on a second read. A value with a `toJSON` is inspected through that method's output; when the source object itself carries a sensitive key, the method is not trusted and the whole value is censored, because a method could rename what it exposes. `DEFAULT_REDACT_PATHS` is still exported at full fidelity, and `redactStrategy: 'paths'` feeds it to `@pinojs/redact` for anyone depending on exact path semantics, with a four-level ceiling and a much higher cost.
885
885
 
886
886
  > [!NOTE]
887
887
  > A bare `sessionId`, `session_id` or `session-id` is **not** on the list: many applications carry one as a correlation key, and a name cannot be switched off one at a time. A session id that is itself a bearer credential in your system must be added to your own `redactPaths` (`redactPaths: ['sessionId']` censors it at any depth under the default strategy).
888
888
 
889
889
  > [!WARNING]
890
- > Redaction matches **key names**. A secret under a name you have not declared sensitive is emitted: `logger.log(key, msg, userId, { renamed: user.password })` writes it in clear, and so does a `toJSON` that renames nested state. No name matcher can follow a value through a rename. Declare the name, or keep the value out of the log.
890
+ > Redaction matches **key names**. A secret under a name you have not declared sensitive is emitted: `logger.info(key, msg, userId, { renamed: user.password })` writes it in clear, and so does a `toJSON` that renames nested state. No name matcher can follow a value through a rename. Declare the name, or keep the value out of the log.
891
891
 
892
892
  **One entry, one line.** Every message argument passes through a normalization before it reaches Pino: line separators (`\r`, `\n`, U+2028, U+2029, U+0085) become the two-character sequence `\n`, and every other control character that can drive a terminal (ESC, vertical tab, form feed, backspace, the rest of C0 except TAB, DEL and the C1 range) becomes a readable `\uXXXX` escape. This keeps a message from forging an entry in `pino-pretty` and in any destination that re-renders it, and `JSON.stringify` alone would leave DEL, C1, U+2028 and U+2029 verbatim in a raw line read in a terminal. The scrubbed stack gets the same escaping (its newlines are kept). Structured fields are untouched, so `err.message` keeps the original text, and a control character in a **metadata value** still reaches a terminal: only `msg` and the stack carry this guarantee.
893
893
 
@@ -952,6 +952,8 @@ No name rule reaches the second case, and scanning values for secret-shaped text
952
952
 
953
953
  `redactStrategy` governs **your** payload: the record, child bindings and the output of any serializer you supply. The built-in `err` serializer is always name-walked, even under `'paths'`, because the four-level ceiling cannot reach the depth of a `cause` chain. Under `'paths'`, an `Error` anywhere in the record is converted with the default names censored in its own fields and its `cause` chain at any depth, with your paths applied on top; non-`Error` data is matched only by the configured paths.
954
954
 
955
+ What you pass to `child()` and `setBindings()`, on the raw logger from `getRawLogger()` too, is redacted, and so is what the `formatters` and `serializers` of child options return. How bindings of the raw logger are redacted follows `redactStrategy`. Under `'names'` they are walked by name, and the `bindings` formatter and the serializers receive that redacted copy, not your objects: a `Date` as a string, a `Map` as `{}`. Under `'paths'`, `child()` of the raw logger leaves them to Pino's redact paths, and your own objects reach the formatters and serializers; the conversion `service.child()` applies does not happen there, so an `Error` under a key other than `err` is written without it, `errorOwnFields: 'safe'` is not applied to that `Error`, and a `Buffer` binding throws. `redact` and `msgPrefix` are applied as you set them: `redact` replaces the Pino paths for that child (under `redactStrategy: 'paths'`, that includes the ones that redact its bindings), and `msgPrefix` is your own text before each message. **The message text is not redacted by name**: a value the raw logger formats into it (`raw.info('user %o', user)`) is not walked, so pass it as a field instead.
956
+
955
957
  #### A value interpolated into the message has no name to redact
956
958
 
957
959
  ```ts
@@ -982,7 +984,7 @@ Every serializer, the default `err` one and any you supply, is wrapped so a fiel
982
984
 
983
985
  `maxEntrySizeBytes` bounds what a serializer returns and the derived exception fields, and a string under a metadata key is the caller's own data, written as given. `maxStringLength` bounds that string too, and is off until set. A string longer than the limit is cut to that many characters (UTF-16 units, so a cut never splits a surrogate pair) and ends with `…[truncated]`; what is written is the limit plus 12 characters at most, and a string of exactly the limit is written whole.
984
986
 
985
- It applies to every string value of the record at any depth, in an object or an array, after redaction: a value a redaction rule censors is the censor and not a cut text. It does not apply to a key, to a value that is not text, to the log message (already capped at 16384 characters), to the `logKey` of the entry (an identifier, and `event.name` is derived from it), to the bindings of a logger (the service identity and the `context` of an `@InjectLogger` logger are written once, whole), to anything under a key that has a serializer (`err` and the keys of `serializers`): this limit does not cut the error you log under `err`, and `maxEntrySizeBytes` caps what a serializer returns when that output serializes to JSON. The event name and the `exception.type`, `exception.message`, `exception.stacktrace` and `error.type` fields written from an error are added after the cut, so the limit does not apply to them, and the exception fields among them are cut by `maxEntrySizeBytes` (in UTF-8 bytes) and by the cap of 16384 characters, and a key of your own with one of those names is cut like any other string. The names left whole are matched on the root key, so a key of your own named like a key of `serializers` is left whole too. An `Error` placed in the metadata under any other key is data of the record when the cut runs, so its message, its stack and its own fields are cut like any other string. The limit is an integer from 64, because the strings the library writes into a record itself (trace and span ids) are shorter than that. A string the caller supplies, such as a `userId`, a `tenantId`, or a `requestId` taken from an inbound request header, is cut like any other when it is longer than the limit. Setting it makes the record walk run even when no field name is covered (`shouldDisableDefaultRedact: true` and no `redactPaths`), and the walk writes a boxed `String` or `Number`, a `Buffer`, a `Uint8Array` and an `Error` in the metadata as the default redaction already does: a two-byte `Buffer` is written as `[Binary 2 bytes]` and not as `{"type":"Buffer","data":[104,105]}`, while a boxed `Number` is written as `{}` and a boxed `String` as a map of its indexes (`{"0":"a","1":"b","2":"c"}` for `new String('abc')`), as the default redaction writes them. A `redactCensor` longer than the limit is refused at startup, because a censor the cut shortened would no longer be the text you look for in place of a secret.
987
+ It applies to every string value of the record at any depth, in an object or an array, after redaction: a value a redaction rule censors is the censor and not a cut text. It does not apply to a key, to a value that is not text, to the log message (capped at 16384 characters; the one exception is the text of an object that is written as the fields of the entry, which is cut), to the `logKey` of the entry (an identifier, and `event.name` is derived from it), to the bindings of a logger (the service identity and the `context` of an `@InjectLogger` logger are written once, whole), to anything under a key that has a serializer (`err` and the keys of `serializers`): this limit does not cut the error you log under `err`, and `maxEntrySizeBytes` caps what a serializer returns when that output serializes to JSON. The event name and the `exception.type`, `exception.message`, `exception.stacktrace` and `error.type` fields written from an error are added after the cut, so the limit does not apply to them, and the exception fields among them are cut by `maxEntrySizeBytes` (in UTF-8 bytes) and by the cap of 16384 characters, and a key of your own with one of those names is cut like any other string. The names left whole are matched on the root key, so a key of your own named like a key of `serializers` is left whole too. An `Error` placed in the metadata under any other key is data of the record when the cut runs, so its message, its stack and its own fields are cut like any other string. The limit is an integer from 64, because the strings the library writes into a record itself (trace and span ids) are shorter than that. A string the caller supplies, such as a `userId`, a `tenantId`, or a `requestId` taken from an inbound request header, is cut like any other when it is longer than the limit. Setting it makes the record walk run even when no field name is covered (`shouldDisableDefaultRedact: true` and no `redactPaths`), and the walk writes a boxed `String` or `Number`, a `Buffer`, a `Uint8Array` and an `Error` in the metadata as the default redaction already does: a two-byte `Buffer` is written as `[Binary 2 bytes]` and not as `{"type":"Buffer","data":[104,105]}`, while a boxed `Number` is written as `{}` and a boxed `String` as a map of its indexes (`{"0":"a","1":"b","2":"c"}` for `new String('abc')`), as the default redaction writes them. A `redactCensor` longer than the limit is refused at startup, because a censor the cut shortened would no longer be the text you look for in place of a secret.
986
988
 
987
989
  ### Security Checklist
988
990
 
@@ -1059,7 +1061,7 @@ Implements NestJS `LoggerService`. All methods are available via `@InjectLogger(
1059
1061
  | `warnStructured` | `(logKey, msg, userId?, meta?)` | Structured warn log — takes a **message string** |
1060
1062
  | `errorStructured` | `(logKey, error, userId?, meta?)` | Structured error log — takes an **`Error`**, serialized to `err` |
1061
1063
 
1062
- `meta` carries arbitrary fields, except that `logKey`, `userId` and `context` belong to the payload (read from the authenticated ALS scope, so a metadata bag cannot forge them), `level`, `time`, `msg`, `service`, `service.*`, `deployment` and `deployment.*` are written by the logger itself and are dropped from `meta`, as are `exception.type`, `exception.message`, `exception.stacktrace` and `error.type`, which the logger derives from an error and which are matched by their own spelling, whatever the case, and not folded further (`exceptionType` is a field of yours, and so is `event.name` on a call that has no log key), and `__proto__`, `constructor` and `prototype` are dropped, since they name a prototype chain rather than a field. A key the logger writes from the request context or from the active span (`requestId`, `tenantId`, the trace fields) keeps the logger's value when the payload carries the same key, for `meta`, an object message and the raw Pino logger alike, except `userId`, which a call names as an argument and which wins over the one of the request context; a key the logger does not write, such as a `requestId` outside a request, keeps the payload's own value. A key that only spells one of these keys, or an owned key, is dropped like the key itself (`Level`, `log_key`, `trace_id` for `traceId`, `request.id` for `requestId`): names are compared with the case, the separators `_`, `.` and `-`, white space, control characters, combining marks and the characters that print as nothing folded, the compatibility forms Unicode defines read as the letter they stand for, and a short list of Cyrillic and Greek letters, the dotless `ı` and the small capitals drawn like a Latin one read as it (`trace id`, `trace\u200bId`, `RequestId`, `rеquestId`), and `service_name`, `service-version` and the other spellings of the dotted resource keys are the keys themselves (a key such as `service_tier`, which spells none of them, is yours), so a backend that normalises names cannot read the payload's copy as the logger's field. A lookalike letter that is not on the list is kept: the list is not every lookalike Unicode has. The raw Pino logger from `getRawLogger()` bypasses the owned-key guards of `meta` and of an object message, so a payload can still repeat `level`, `service` or `userId` there; the request and trace keys still win, and redaction still applies.
1064
+ `meta` carries arbitrary fields, except that `logKey`, `userId` and `context` belong to the payload (read from the authenticated ALS scope, so a metadata bag cannot forge them), `level`, `time`, `msg`, `service`, `service.*`, `deployment` and `deployment.*` are written by the logger itself and are dropped from `meta`, as are `exception.type`, `exception.message`, `exception.stacktrace` and `error.type`, which the logger derives from an error and which are matched by their own spelling, whatever the case, and not folded further (`exceptionType` is a field of yours, and so is `event.name` on a call that has no log key), and `__proto__`, `constructor` and `prototype` are dropped, since they name a prototype chain rather than a field. A key the logger writes from the request context or from the active span (`requestId`, `tenantId`, the trace fields) keeps the logger's value when the payload carries the same key, for `meta`, an object message and the raw Pino logger alike, except `userId`, which a call names as an argument and which wins over the one of the request context; a key the logger does not write, such as a `requestId` outside a request, keeps the payload's own value. A key that only spells one of these keys, or an owned key, is dropped like the key itself (`Level`, `log_key`, `trace_id` for `traceId`, `request.id` for `requestId`): names are compared with the case, the separators `_`, `.` and `-`, white space, control characters, combining marks and the characters that print as nothing folded, the compatibility forms Unicode defines read as the letter they stand for, and a short list of Cyrillic and Greek letters, the dotless `ı` and the small capitals drawn like a Latin one read as it (`trace id`, `trace\u200bId`, `RequestId`, `rеquestId`), and `service_name`, `service-version` and the other spellings of the dotted resource keys are the keys themselves (a key such as `service_tier`, which spells none of them, is yours), so a backend that normalises names cannot read the payload's copy as the logger's field. A lookalike letter that is not on the list is kept: the list is not every lookalike Unicode has. The raw Pino logger from `getRawLogger()` bypasses the owned-key guards of `meta` and of an object message, so a payload can still repeat `level`, `service` or `userId` there; the request and trace keys still win, and its fields are still redacted (its message text is not walked by name: see [what redaction covers](#what-redaction-covers-and-what-it-cannot)).
1063
1065
 
1064
1066
  **NestJS `LoggerService` bridge** — the variadic contract NestJS calls, so `app.useLogger()` works. These take a message, not a log key.
1065
1067
 
@@ -1381,8 +1381,8 @@ function writeName(value, level, host, depth2) {
1381
1381
  const censored = host.censorName(typeof value === "string" ? cutText(value) : value);
1382
1382
  return censored === value ? cutOrWalk(value, level, host, depth2) : censored;
1383
1383
  }
1384
- function addErrorParts(copy, error, ownKeys, host, depth2) {
1385
- const taken = capturedSet(ownKeys);
1384
+ function addErrorParts(copy, error, ownKeys2, host, depth2) {
1385
+ const taken = capturedSet(ownKeys2);
1386
1386
  const level = linkDepths.get(error) ?? 0;
1387
1387
  let incomplete = false;
1388
1388
  const add = (key, covers, read, write = (value) => walkChainPart(value, level, host, depth2)) => {
@@ -3366,6 +3366,82 @@ function destinationToStream(destination, health, maxQueueBytes = 0, censorMessa
3366
3366
  return stream;
3367
3367
  }
3368
3368
 
3369
+ // src/server/utils/guard-child-bindings.util.ts
3370
+ var apply = Reflect.apply;
3371
+ var create = Object.create;
3372
+ var defineProperty2 = Object.defineProperty;
3373
+ var getOwnPropertyDescriptors = Object.getOwnPropertyDescriptors;
3374
+ var getPrototypeOf = Object.getPrototypeOf;
3375
+ var hasOwn2 = Object.hasOwn;
3376
+ var ownKeys = Reflect.ownKeys;
3377
+ function followedBy(run2, then) {
3378
+ if (typeof run2 !== "function") return run2;
3379
+ return function(...inputs) {
3380
+ return then(apply(run2, this, inputs));
3381
+ };
3382
+ }
3383
+ var asPassed = (value) => value;
3384
+ function replacing(source, replaced) {
3385
+ const descriptors = getOwnPropertyDescriptors(source);
3386
+ for (const key in replaced) descriptors[key] = { value: replaced[key] };
3387
+ for (const name of ownKeys(descriptors)) {
3388
+ descriptors[name] = bareDescriptor(descriptors[name]);
3389
+ }
3390
+ return create(getPrototypeOf(source), descriptors);
3391
+ }
3392
+ function guardFormatters(formatters, guard) {
3393
+ const { bindings, level, log } = formatters;
3394
+ return replacing(formatters, {
3395
+ bindings: followedBy(bindings, (output) => guard.redactBindings(output, true)),
3396
+ level: followedBy(level, (output) => guard.redactSerialized(output)),
3397
+ // A formatter that returns nothing is passed on as it is: Pino writes no fields for it.
3398
+ log: followedBy(
3399
+ log,
3400
+ (output) => output ? guard.formatRecord(output) : output
3401
+ )
3402
+ });
3403
+ }
3404
+ function guardSerializers(serializers, redact) {
3405
+ const source = serializers;
3406
+ const guarded = {};
3407
+ for (const key in source) {
3408
+ const value = followedBy(source[key], (output) => redact(output));
3409
+ defineProperty2(guarded, key, bareDescriptor({ value, enumerable: true }));
3410
+ }
3411
+ return guarded;
3412
+ }
3413
+ function guardOptions2(options, guard) {
3414
+ if (typeof options !== "object" || options === null) return options;
3415
+ const { formatters, serializers } = options;
3416
+ const replaced = {};
3417
+ if (hasOwn2(options, "formatters") && formatters) {
3418
+ replaced["formatters"] = guardFormatters(formatters, guard);
3419
+ }
3420
+ if (hasOwn2(options, "serializers") && serializers) {
3421
+ replaced["serializers"] = guardSerializers(serializers, guard.redactSerialized);
3422
+ }
3423
+ return replacing(options, replaced);
3424
+ }
3425
+ function guardChildBindings(logger, redaction, options) {
3426
+ const guard = options.redactStrategy === "names" ? redaction : { ...redaction, redactBindings: asPassed };
3427
+ const nativeChild = logger.child;
3428
+ const nativeSetBindings = logger.setBindings;
3429
+ const redacted = (bindings) => bindings ? guard.redactBindings(bindings, true) : bindings;
3430
+ const child = function(bindings, options2) {
3431
+ return apply(nativeChild, this, [
3432
+ redacted(bindings),
3433
+ guardOptions2(options2, guard)
3434
+ ]);
3435
+ };
3436
+ const setBindings = function(bindings) {
3437
+ apply(nativeSetBindings, this, [redacted(bindings)]);
3438
+ };
3439
+ const open = { writable: true, configurable: true };
3440
+ defineProperty2(logger, "child", bareDescriptor({ ...open, value: child }));
3441
+ defineProperty2(logger, "setBindings", bareDescriptor({ ...open, value: setBindings }));
3442
+ return logger;
3443
+ }
3444
+
3369
3445
  // src/server/utils/merge-mixin-safely.util.ts
3370
3446
  var PROTOTYPE_KEY = "__proto__";
3371
3447
  var EXPLICIT_USER_KEY = "userId";
@@ -4100,28 +4176,19 @@ function buildRecordFormatter(options, redactRecord, onTruncate) {
4100
4176
  );
4101
4177
  };
4102
4178
  }
4103
- function buildFormatters(options, redactRecord, redactBindings, onTruncate) {
4179
+ function buildFormatters(redactBindings, formatRecord) {
4104
4180
  return {
4105
- // Emit the level as a string label instead of the numeric code — easier
4106
- // for log aggregators. Trace context is injected via `mixin`, never via
4107
- // `formatters.log` (which cannot see ambient ALS / OTel state).
4181
+ // The level as a label, easier for log aggregators. Trace context comes from `mixin`:
4182
+ // `formatters.log` cannot see ambient ALS / OTel state.
4108
4183
  level: (label) => ({ level: label }),
4109
- // `base` bindings never reach `formatters.log` — Pino pre-serializes them
4110
- // into the instance's `chindings`, the same reason `child()` has to redact
4111
- // its own. That matters because `service` is CONSUMER-supplied and
4112
- // `applyDefaults` keeps whatever it was given: a `{ name, version, apiKey }`
4113
- // went out in clear, where the path expansion had covered it via `*.*.apiKey`.
4114
- // Redacting here rather than trimming to the two declared fields keeps a
4115
- // consumer's extra metadata instead of silently dropping it. Runs ONCE, at
4116
- // logger construction — no per-entry cost. `true`: bindings are a record
4117
- // root, iterated rather than serialized.
4184
+ // `base` bindings never reach `formatters.log`: Pino pre-serializes them into `chindings`.
4185
+ // `service` is CONSUMER-supplied and `applyDefaults` keeps whatever it was given, so a
4186
+ // `{ name, version, apiKey }` is redacted here, which keeps the consumer's extra metadata
4187
+ // where trimming to the two declared fields would drop it. Runs ONCE, at logger
4188
+ // construction. `true`: bindings are a record root, iterated rather than serialized.
4118
4189
  bindings: (bindings) => redactBindings(bindings, true),
4119
- // The name-walk redactor runs here, on the merged record (mixin output +
4120
- // the caller's object), which is exactly the surface a caller controls.
4121
- // `base` and child bindings are NOT visible at this hook — they are
4122
- // library-owned (`service`, the `@InjectLogger` context) and carry nothing
4123
- // sensitive, which `pino-factory.spec.ts` pins.
4124
- log: buildRecordFormatter(options, redactRecord, onTruncate)
4190
+ // The record, not bindings: `base` is redacted above, and a child's by `guardChildBindings`.
4191
+ log: formatRecord
4125
4192
  };
4126
4193
  }
4127
4194
  var UNSET_PINO_NAMES = {
@@ -4144,9 +4211,11 @@ function buildPinoInstance(options, logContext, destinations, health) {
4144
4211
  refuseUnsafeOptions(options);
4145
4212
  const redactRecord = resolveRecordRedactor(options);
4146
4213
  const redactSerialized = buildNameRedactor(options);
4214
+ const redactBindings = resolveNameRedactor(options);
4147
4215
  const ownFields = ownFieldPolicyOf(options);
4148
4216
  const redactOption = resolveRedactOption(options);
4149
4217
  const onTruncate = (reason) => health.recordTruncation(reason);
4218
+ const formatRecord = buildRecordFormatter(options, redactRecord, onTruncate);
4150
4219
  const pinoOptions = {
4151
4220
  level: options.level,
4152
4221
  ...redactOption === void 0 ? {} : { redact: { ...redactOption, remove: false } },
@@ -4163,13 +4232,14 @@ function buildPinoInstance(options, logContext, destinations, health) {
4163
4232
  // is encoded as a JSON string here: a quote, a backslash or a newline in it must
4164
4233
  // neither break the line nor add fields to it.
4165
4234
  timestamp: () => `,"time":${JSON.stringify(String(options.timestamp()))}`,
4166
- formatters: buildFormatters(options, redactRecord, resolveNameRedactor(options), onTruncate),
4235
+ formatters: buildFormatters(redactBindings, formatRecord),
4167
4236
  serializers: buildSerializers(options, redactSerialized, ownFields, onTruncate),
4168
4237
  mixin: buildTraceMixin(logContext, options),
4169
4238
  mixinMergeStrategy: mergeMixinSafely
4170
4239
  };
4171
4240
  const streams = pino__default.default.multistream(buildStreams(options, destinations, health));
4172
- return withEntryTextFinisher(pino__default.default(pinoOptions, streams), options, onTruncate);
4241
+ const logger = withEntryTextFinisher(pino__default.default(pinoOptions, streams), options, onTruncate);
4242
+ return guardChildBindings(logger, { redactBindings, redactSerialized, formatRecord }, options);
4173
4243
  }
4174
4244
  var DROP_REPORT_INTERVAL_MS = 1e4;
4175
4245
  function countInWindow(records, destination, now) {
@@ -470,10 +470,10 @@ interface DestinationQueueOptions {
470
470
  /**
471
471
  * The time application shutdown has to flush the destinations.
472
472
  *
473
- * Shutdown first drains the queue each destination holds, then calls each destination's
474
- * `onShutdown` in reverse registration order. The whole sequence is bounded by `timeoutMs`, whatever
475
- * the number of destinations: a destination reached after the budget is spent is reported as skipped
476
- * and its `onShutdown` is not called.
473
+ * Shutdown first drains the queue each destination holds, then calls, in reverse registration
474
+ * order, the `onShutdown` of each destination that did not fail to initialize. The whole sequence is
475
+ * bounded by `timeoutMs`, whatever the number of destinations: a destination reached after the
476
+ * budget is spent is reported as skipped and its `onShutdown` is not called.
477
477
  */
478
478
  interface ShutdownOptions {
479
479
  /**
@@ -532,18 +532,19 @@ interface BymaxLoggerModuleOptions {
532
532
  */
533
533
  shouldUseAsNestLogger?: boolean;
534
534
  /**
535
- * Additional `fast-redact` paths, applied on top of the default coverage
536
- * whatever `redactStrategy` is in force.
535
+ * Additional `@pinojs/redact` paths, applied on top of the default coverage
536
+ * whatever `redactStrategy` is in force. Pino ships `@pinojs/redact` from
537
+ * `10.1.0`; `10.0.0` ships `slow-redact` in its place.
537
538
  */
538
539
  redactPaths?: readonly string[];
539
540
  /**
540
541
  * Engine backing the DEFAULT redaction set (never the consumer's own
541
- * `redactPaths`, which are always `fast-redact` paths).
542
+ * `redactPaths`, which are always `@pinojs/redact` paths).
542
543
  *
543
544
  * - `'names'` (default) — one recursive walk censoring any value whose KEY
544
545
  * NAME is in `REDACT_COMMON_FIELDS`, at ANY depth. ~943 k logs/s.
545
546
  * - `'paths'` — the pre-1.2 engine: `DEFAULT_REDACT_PATHS` handed to
546
- * `fast-redact`. Matches only wildcard depths 1–4 and measures ~9.3 k
547
+ * `@pinojs/redact`. Matches only wildcard depths 1–4 and measures ~9.3 k
547
548
  * logs/s. Provided as an escape hatch for a consumer depending on exact
548
549
  * path-matching semantics; expect it to be removed in a future major.
549
550
  */
@@ -625,14 +626,15 @@ interface BymaxLoggerModuleOptions {
625
626
  */
626
627
  maxEntrySizeBytes?: number;
627
628
  /**
628
- * The most characters a string of a log record is written with. A longer string is cut to this
629
- * many characters, without splitting a surrogate pair, and ends with `…[truncated]`, so what is
630
- * written is up to 12 characters longer than the limit. An integer from 64 to 2147483647.
631
- * Default: not set, and a string is written whole.
629
+ * The most characters a string value of a log record is written with, with the exceptions below.
630
+ * A longer string is cut to this many characters, without splitting a surrogate pair, and ends
631
+ * with `…[truncated]`, so what is written is up to 12 characters longer than the limit. An integer
632
+ * from 64 to 2147483647. Default: not set, and a string is written whole.
632
633
  *
633
634
  * Applies to every string value of the record at any depth, but not to a key, a value that is
634
- * not text, the log message (already capped at 16384 characters), the `logKey`, the bindings of a
635
- * logger (the service identity and a `context`), a value a redaction rule censors, or anything
635
+ * not text, the log message (capped at 16384 characters; the one exception is the text of an
636
+ * object that is written as the fields of the entry, which is cut), the `logKey`, the bindings of
637
+ * a logger (the service identity and a `context`), a value a redaction rule censors, or anything
636
638
  * under a key that has a serializer (`err` and the keys of `serializers`; see
637
639
  * `maxEntrySizeBytes`), so the stack of an error logged under `err` is never cut by it. The event
638
640
  * name and the `exception.*` and `error.type` fields the library writes are added after the cut,
@@ -2140,7 +2142,7 @@ declare const LOG_CONTEXT_TOKEN: unique symbol;
2140
2142
  */
2141
2143
  declare const REDACT_COMMON_FIELDS: readonly string[];
2142
2144
  /**
2143
- * The legacy `fast-redact` path expansion of {@link REDACT_COMMON_FIELDS}:
2145
+ * The legacy `@pinojs/redact` path expansion of {@link REDACT_COMMON_FIELDS}:
2144
2146
  * every name at the record root plus wildcard depths 1–4, followed by the
2145
2147
  * absolute header paths. Length is derived, not fixed — `fields × 5 + absolute`.
2146
2148
  *
@@ -2150,7 +2152,7 @@ declare const REDACT_COMMON_FIELDS: readonly string[];
2150
2152
  * The bare field names come first, at depth 0 — the log record's own root.
2151
2153
  * `emitStructured` spreads caller metadata there (`{ ...metadata, logKey, ... }`),
2152
2154
  * so a field named `password` passed as metadata lands at the root, which the
2153
- * depth-1-and-deeper wildcards below never reach (`fast-redact`'s `*` matches a
2155
+ * depth-1-and-deeper wildcards below never reach (`@pinojs/redact`'s `*` matches a
2154
2156
  * level, not the root). Without the bare name the library's own documented call
2155
2157
  * `logger.info(key, msg, userId, { password })` would write the password in clear.
2156
2158
  * Listing it makes the default set cover a sensitive field wherever it appears.
@@ -470,10 +470,10 @@ interface DestinationQueueOptions {
470
470
  /**
471
471
  * The time application shutdown has to flush the destinations.
472
472
  *
473
- * Shutdown first drains the queue each destination holds, then calls each destination's
474
- * `onShutdown` in reverse registration order. The whole sequence is bounded by `timeoutMs`, whatever
475
- * the number of destinations: a destination reached after the budget is spent is reported as skipped
476
- * and its `onShutdown` is not called.
473
+ * Shutdown first drains the queue each destination holds, then calls, in reverse registration
474
+ * order, the `onShutdown` of each destination that did not fail to initialize. The whole sequence is
475
+ * bounded by `timeoutMs`, whatever the number of destinations: a destination reached after the
476
+ * budget is spent is reported as skipped and its `onShutdown` is not called.
477
477
  */
478
478
  interface ShutdownOptions {
479
479
  /**
@@ -532,18 +532,19 @@ interface BymaxLoggerModuleOptions {
532
532
  */
533
533
  shouldUseAsNestLogger?: boolean;
534
534
  /**
535
- * Additional `fast-redact` paths, applied on top of the default coverage
536
- * whatever `redactStrategy` is in force.
535
+ * Additional `@pinojs/redact` paths, applied on top of the default coverage
536
+ * whatever `redactStrategy` is in force. Pino ships `@pinojs/redact` from
537
+ * `10.1.0`; `10.0.0` ships `slow-redact` in its place.
537
538
  */
538
539
  redactPaths?: readonly string[];
539
540
  /**
540
541
  * Engine backing the DEFAULT redaction set (never the consumer's own
541
- * `redactPaths`, which are always `fast-redact` paths).
542
+ * `redactPaths`, which are always `@pinojs/redact` paths).
542
543
  *
543
544
  * - `'names'` (default) — one recursive walk censoring any value whose KEY
544
545
  * NAME is in `REDACT_COMMON_FIELDS`, at ANY depth. ~943 k logs/s.
545
546
  * - `'paths'` — the pre-1.2 engine: `DEFAULT_REDACT_PATHS` handed to
546
- * `fast-redact`. Matches only wildcard depths 1–4 and measures ~9.3 k
547
+ * `@pinojs/redact`. Matches only wildcard depths 1–4 and measures ~9.3 k
547
548
  * logs/s. Provided as an escape hatch for a consumer depending on exact
548
549
  * path-matching semantics; expect it to be removed in a future major.
549
550
  */
@@ -625,14 +626,15 @@ interface BymaxLoggerModuleOptions {
625
626
  */
626
627
  maxEntrySizeBytes?: number;
627
628
  /**
628
- * The most characters a string of a log record is written with. A longer string is cut to this
629
- * many characters, without splitting a surrogate pair, and ends with `…[truncated]`, so what is
630
- * written is up to 12 characters longer than the limit. An integer from 64 to 2147483647.
631
- * Default: not set, and a string is written whole.
629
+ * The most characters a string value of a log record is written with, with the exceptions below.
630
+ * A longer string is cut to this many characters, without splitting a surrogate pair, and ends
631
+ * with `…[truncated]`, so what is written is up to 12 characters longer than the limit. An integer
632
+ * from 64 to 2147483647. Default: not set, and a string is written whole.
632
633
  *
633
634
  * Applies to every string value of the record at any depth, but not to a key, a value that is
634
- * not text, the log message (already capped at 16384 characters), the `logKey`, the bindings of a
635
- * logger (the service identity and a `context`), a value a redaction rule censors, or anything
635
+ * not text, the log message (capped at 16384 characters; the one exception is the text of an
636
+ * object that is written as the fields of the entry, which is cut), the `logKey`, the bindings of
637
+ * a logger (the service identity and a `context`), a value a redaction rule censors, or anything
636
638
  * under a key that has a serializer (`err` and the keys of `serializers`; see
637
639
  * `maxEntrySizeBytes`), so the stack of an error logged under `err` is never cut by it. The event
638
640
  * name and the `exception.*` and `error.type` fields the library writes are added after the cut,
@@ -2140,7 +2142,7 @@ declare const LOG_CONTEXT_TOKEN: unique symbol;
2140
2142
  */
2141
2143
  declare const REDACT_COMMON_FIELDS: readonly string[];
2142
2144
  /**
2143
- * The legacy `fast-redact` path expansion of {@link REDACT_COMMON_FIELDS}:
2145
+ * The legacy `@pinojs/redact` path expansion of {@link REDACT_COMMON_FIELDS}:
2144
2146
  * every name at the record root plus wildcard depths 1–4, followed by the
2145
2147
  * absolute header paths. Length is derived, not fixed — `fields × 5 + absolute`.
2146
2148
  *
@@ -2150,7 +2152,7 @@ declare const REDACT_COMMON_FIELDS: readonly string[];
2150
2152
  * The bare field names come first, at depth 0 — the log record's own root.
2151
2153
  * `emitStructured` spreads caller metadata there (`{ ...metadata, logKey, ... }`),
2152
2154
  * so a field named `password` passed as metadata lands at the root, which the
2153
- * depth-1-and-deeper wildcards below never reach (`fast-redact`'s `*` matches a
2155
+ * depth-1-and-deeper wildcards below never reach (`@pinojs/redact`'s `*` matches a
2154
2156
  * level, not the root). Without the bare name the library's own documented call
2155
2157
  * `logger.info(key, msg, userId, { password })` would write the password in clear.
2156
2158
  * Listing it makes the default set cover a sensitive field wherever it appears.
@@ -1378,8 +1378,8 @@ function writeName(value, level, host, depth2) {
1378
1378
  const censored = host.censorName(typeof value === "string" ? cutText(value) : value);
1379
1379
  return censored === value ? cutOrWalk(value, level, host, depth2) : censored;
1380
1380
  }
1381
- function addErrorParts(copy, error, ownKeys, host, depth2) {
1382
- const taken = capturedSet(ownKeys);
1381
+ function addErrorParts(copy, error, ownKeys2, host, depth2) {
1382
+ const taken = capturedSet(ownKeys2);
1383
1383
  const level = linkDepths.get(error) ?? 0;
1384
1384
  let incomplete = false;
1385
1385
  const add = (key, covers, read, write = (value) => walkChainPart(value, level, host, depth2)) => {
@@ -3363,6 +3363,82 @@ function destinationToStream(destination, health, maxQueueBytes = 0, censorMessa
3363
3363
  return stream;
3364
3364
  }
3365
3365
 
3366
+ // src/server/utils/guard-child-bindings.util.ts
3367
+ var apply = Reflect.apply;
3368
+ var create = Object.create;
3369
+ var defineProperty2 = Object.defineProperty;
3370
+ var getOwnPropertyDescriptors = Object.getOwnPropertyDescriptors;
3371
+ var getPrototypeOf = Object.getPrototypeOf;
3372
+ var hasOwn2 = Object.hasOwn;
3373
+ var ownKeys = Reflect.ownKeys;
3374
+ function followedBy(run2, then) {
3375
+ if (typeof run2 !== "function") return run2;
3376
+ return function(...inputs) {
3377
+ return then(apply(run2, this, inputs));
3378
+ };
3379
+ }
3380
+ var asPassed = (value) => value;
3381
+ function replacing(source, replaced) {
3382
+ const descriptors = getOwnPropertyDescriptors(source);
3383
+ for (const key in replaced) descriptors[key] = { value: replaced[key] };
3384
+ for (const name of ownKeys(descriptors)) {
3385
+ descriptors[name] = bareDescriptor(descriptors[name]);
3386
+ }
3387
+ return create(getPrototypeOf(source), descriptors);
3388
+ }
3389
+ function guardFormatters(formatters, guard) {
3390
+ const { bindings, level, log } = formatters;
3391
+ return replacing(formatters, {
3392
+ bindings: followedBy(bindings, (output) => guard.redactBindings(output, true)),
3393
+ level: followedBy(level, (output) => guard.redactSerialized(output)),
3394
+ // A formatter that returns nothing is passed on as it is: Pino writes no fields for it.
3395
+ log: followedBy(
3396
+ log,
3397
+ (output) => output ? guard.formatRecord(output) : output
3398
+ )
3399
+ });
3400
+ }
3401
+ function guardSerializers(serializers, redact) {
3402
+ const source = serializers;
3403
+ const guarded = {};
3404
+ for (const key in source) {
3405
+ const value = followedBy(source[key], (output) => redact(output));
3406
+ defineProperty2(guarded, key, bareDescriptor({ value, enumerable: true }));
3407
+ }
3408
+ return guarded;
3409
+ }
3410
+ function guardOptions2(options, guard) {
3411
+ if (typeof options !== "object" || options === null) return options;
3412
+ const { formatters, serializers } = options;
3413
+ const replaced = {};
3414
+ if (hasOwn2(options, "formatters") && formatters) {
3415
+ replaced["formatters"] = guardFormatters(formatters, guard);
3416
+ }
3417
+ if (hasOwn2(options, "serializers") && serializers) {
3418
+ replaced["serializers"] = guardSerializers(serializers, guard.redactSerialized);
3419
+ }
3420
+ return replacing(options, replaced);
3421
+ }
3422
+ function guardChildBindings(logger, redaction, options) {
3423
+ const guard = options.redactStrategy === "names" ? redaction : { ...redaction, redactBindings: asPassed };
3424
+ const nativeChild = logger.child;
3425
+ const nativeSetBindings = logger.setBindings;
3426
+ const redacted = (bindings) => bindings ? guard.redactBindings(bindings, true) : bindings;
3427
+ const child = function(bindings, options2) {
3428
+ return apply(nativeChild, this, [
3429
+ redacted(bindings),
3430
+ guardOptions2(options2, guard)
3431
+ ]);
3432
+ };
3433
+ const setBindings = function(bindings) {
3434
+ apply(nativeSetBindings, this, [redacted(bindings)]);
3435
+ };
3436
+ const open = { writable: true, configurable: true };
3437
+ defineProperty2(logger, "child", bareDescriptor({ ...open, value: child }));
3438
+ defineProperty2(logger, "setBindings", bareDescriptor({ ...open, value: setBindings }));
3439
+ return logger;
3440
+ }
3441
+
3366
3442
  // src/server/utils/merge-mixin-safely.util.ts
3367
3443
  var PROTOTYPE_KEY = "__proto__";
3368
3444
  var EXPLICIT_USER_KEY = "userId";
@@ -4097,28 +4173,19 @@ function buildRecordFormatter(options, redactRecord, onTruncate) {
4097
4173
  );
4098
4174
  };
4099
4175
  }
4100
- function buildFormatters(options, redactRecord, redactBindings, onTruncate) {
4176
+ function buildFormatters(redactBindings, formatRecord) {
4101
4177
  return {
4102
- // Emit the level as a string label instead of the numeric code — easier
4103
- // for log aggregators. Trace context is injected via `mixin`, never via
4104
- // `formatters.log` (which cannot see ambient ALS / OTel state).
4178
+ // The level as a label, easier for log aggregators. Trace context comes from `mixin`:
4179
+ // `formatters.log` cannot see ambient ALS / OTel state.
4105
4180
  level: (label) => ({ level: label }),
4106
- // `base` bindings never reach `formatters.log` — Pino pre-serializes them
4107
- // into the instance's `chindings`, the same reason `child()` has to redact
4108
- // its own. That matters because `service` is CONSUMER-supplied and
4109
- // `applyDefaults` keeps whatever it was given: a `{ name, version, apiKey }`
4110
- // went out in clear, where the path expansion had covered it via `*.*.apiKey`.
4111
- // Redacting here rather than trimming to the two declared fields keeps a
4112
- // consumer's extra metadata instead of silently dropping it. Runs ONCE, at
4113
- // logger construction — no per-entry cost. `true`: bindings are a record
4114
- // root, iterated rather than serialized.
4181
+ // `base` bindings never reach `formatters.log`: Pino pre-serializes them into `chindings`.
4182
+ // `service` is CONSUMER-supplied and `applyDefaults` keeps whatever it was given, so a
4183
+ // `{ name, version, apiKey }` is redacted here, which keeps the consumer's extra metadata
4184
+ // where trimming to the two declared fields would drop it. Runs ONCE, at logger
4185
+ // construction. `true`: bindings are a record root, iterated rather than serialized.
4115
4186
  bindings: (bindings) => redactBindings(bindings, true),
4116
- // The name-walk redactor runs here, on the merged record (mixin output +
4117
- // the caller's object), which is exactly the surface a caller controls.
4118
- // `base` and child bindings are NOT visible at this hook — they are
4119
- // library-owned (`service`, the `@InjectLogger` context) and carry nothing
4120
- // sensitive, which `pino-factory.spec.ts` pins.
4121
- log: buildRecordFormatter(options, redactRecord, onTruncate)
4187
+ // The record, not bindings: `base` is redacted above, and a child's by `guardChildBindings`.
4188
+ log: formatRecord
4122
4189
  };
4123
4190
  }
4124
4191
  var UNSET_PINO_NAMES = {
@@ -4141,9 +4208,11 @@ function buildPinoInstance(options, logContext, destinations, health) {
4141
4208
  refuseUnsafeOptions(options);
4142
4209
  const redactRecord = resolveRecordRedactor(options);
4143
4210
  const redactSerialized = buildNameRedactor(options);
4211
+ const redactBindings = resolveNameRedactor(options);
4144
4212
  const ownFields = ownFieldPolicyOf(options);
4145
4213
  const redactOption = resolveRedactOption(options);
4146
4214
  const onTruncate = (reason) => health.recordTruncation(reason);
4215
+ const formatRecord = buildRecordFormatter(options, redactRecord, onTruncate);
4147
4216
  const pinoOptions = {
4148
4217
  level: options.level,
4149
4218
  ...redactOption === void 0 ? {} : { redact: { ...redactOption, remove: false } },
@@ -4160,13 +4229,14 @@ function buildPinoInstance(options, logContext, destinations, health) {
4160
4229
  // is encoded as a JSON string here: a quote, a backslash or a newline in it must
4161
4230
  // neither break the line nor add fields to it.
4162
4231
  timestamp: () => `,"time":${JSON.stringify(String(options.timestamp()))}`,
4163
- formatters: buildFormatters(options, redactRecord, resolveNameRedactor(options), onTruncate),
4232
+ formatters: buildFormatters(redactBindings, formatRecord),
4164
4233
  serializers: buildSerializers(options, redactSerialized, ownFields, onTruncate),
4165
4234
  mixin: buildTraceMixin(logContext, options),
4166
4235
  mixinMergeStrategy: mergeMixinSafely
4167
4236
  };
4168
4237
  const streams = pino.multistream(buildStreams(options, destinations, health));
4169
- return withEntryTextFinisher(pino(pinoOptions, streams), options, onTruncate);
4238
+ const logger = withEntryTextFinisher(pino(pinoOptions, streams), options, onTruncate);
4239
+ return guardChildBindings(logger, { redactBindings, redactSerialized, formatRecord }, options);
4170
4240
  }
4171
4241
  var DROP_REPORT_INTERVAL_MS = 1e4;
4172
4242
  function countInWindow(records, destination, now) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bymax-one/nest-logger",
3
- "version": "1.4.33",
3
+ "version": "1.4.35",
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",