@bymax-one/nest-logger 1.4.28 → 1.4.30

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,159 @@ heading here.
12
12
 
13
13
  ## [Unreleased]
14
14
 
15
+ ## [1.4.30] - 2026-11-24
16
+
17
+ ### Breaking
18
+
19
+ - **`LoggerHealthIndicator.check()` answers a frozen verdict.** The result and its `details` are
20
+ frozen, so code that adds or changes a field on the result that `check()` resolves to throws a `TypeError` in strict
21
+ mode (and drops the write silently in sloppy mode). Migration: copy before you mutate, for example
22
+ `const verdict = { ...result, details: { ...result.details } }`, and change the copy.
23
+ The result also has no prototype, so `result.hasOwnProperty(...)` and a template string of it throw
24
+ a `TypeError`, and `assert.deepStrictEqual` against a plain object fails; the same spread copy is a
25
+ plain object, so compare or call methods on the copy. `details` is an ordinary frozen object.
26
+
27
+ ### Fixed
28
+
29
+ - **A replaced `Promise.resolve`, a replaced `Promise.prototype.constructor` and a `then` planted on a
30
+ prototype root no longer decide what the logger awaits, in the cases measured here.** Measured: with `Promise.resolve` replaced after
31
+ the import, the health indicator answered `up` for a delivery with no healthy sink, `withTimeout` settled a
32
+ hook that had rejected, a failed destination write was not recorded for readiness, and a late rejection of a
33
+ tenant resolver reached the process. The sites no longer read a static of `Promise`: a promise the
34
+ library builds comes from the intrinsic constructor (taken from an async function, so a `globalThis.Promise`
35
+ set before the load is not it), a wait is an `await`, and the outcome of a wait is a box with no prototype.
36
+ Before each `await` that feeds a verdict the baseline is asserted, with no call of the host between the
37
+ check and the wait: `Promise.prototype.constructor` is the intrinsic one and no `then` sits on
38
+ `Object.prototype`, `Array.prototype` or `Function.prototype`. A failed assertion refuses the verdict: a
39
+ hook is reported as failed, a write is recorded as failed and reported on stderr. A `then` of
40
+ `Promise.prototype` that a runtime wraps (a context manager) is allowed. `withTimeout` now resolves with
41
+ nothing. A source scan fails for a new read of a static, a
42
+ `new Promise`, `.then(`, `.catch(` or `.finally(` in `src`.
43
+ A native promise a hook or a destination returns is waited for through the intrinsic constructor, for the
44
+ length of one synchronous call, and is refused when it already carries its own `constructor` or `then`
45
+ or cannot take that slot.
46
+ Known limits: a frozen, sealed or non-extensible native promise cannot take a handler under a replaced
47
+ `Promise.prototype.constructor` whose species throws, so a rejection of it can reach the process (a
48
+ waited-for promise of that shape is refused instead); while a rejection is absorbed, the temporary
49
+ `constructor` of the promise can stay if a species getter makes it non-configurable inside that window;
50
+ code running concurrently that plants a `then` and erases it again between the check and the
51
+ work's own settlement cannot be seen afterwards, and a dependency that reads a static inside itself is code
52
+ aimed at that dependency, not at the logger. Code that replaces the `constructor` of `Promise.prototype`
53
+ before this package is loaded is not detected either: the intrinsic is read from that slot at load, so
54
+ the baseline is the replacement. These guards are best-effort hardening, not a security
55
+ boundary: code running inside the host process is trusted (SECURITY.md, "Threat model: same-process
56
+ code"). A descriptor read by these guards, and by the `toJSON` lookup outside `errorOwnFields: 'safe'` and the options filter, is read for
57
+ its own `get` and `value` only, so a field planted on `Object.prototype` is not taken for one.
58
+ - **A key planted on `Object.prototype` is no option.** The options were read by property access through
59
+ the prototype chain, so a `shouldDisableDefaultRedact: true` planted on `Object.prototype` (by a
60
+ dependency with a prototype-pollution flaw) turned the default redact paths off, and `redactCensor`,
61
+ `level` and the rest were read the same way. A value that only a root prototype (one with no prototype of its own, such as the
62
+ `Object.prototype` of any realm) holds is now skipped, the options and their groups are kept in objects
63
+ with no prototype, and so is the `service` metadata; a key the object has itself, and a getter a class
64
+ prototype defines, still count. A built-in that the redaction reads and a program replaces after the import drops the record and redacts a URL path whole: each one in the table (`GUARDED_BUILTINS` in `src/server/utils/captured-builtins.util.ts`, held by a spec to the calls of five files: `fold-key`, `normalize-url`, `matches-exclude-path`, `sanitize-error` and `pino-factory`) is compared with the one the module loaded with. What `redact-by-name`, the error-text exemption, `redact-error-parts`, the mixin merge, the truncation and `bounded-text` call is outside the table. A value whose prototype chain does not end within the bound in `resolve-to-json.util.ts` is written as the censor. What was replaced before the import is outside this. A `get` or `set` installed with `Object.defineProperty` (an accessor, which plain assignment cannot make) is outside what this guards. A `get` or a `set` planted there no longer reaches a descriptor the logger
65
+ defines, and options read through a Proxy under a planted accessor of the same name are refused. Pino got the same: it is handed an own value for each option it reads
66
+ and the library does not set, and so is each entry handed to its multistream, so a planted one is not
67
+ seen. Out of scope, because Node and Pino read them off objects this library does
68
+ not build: keys such as `message` and `toJSON`, which the emit and `JSON.stringify` read.
69
+ A key planted by plain assignment, so that it is enumerable, under `level`, `msgPrefix` or `levelVal`
70
+ makes Pino throw while the logger is built, and under `levels` at the first Nest-style log call, since
71
+ Pino assigns to its instance every key a `for...in` over its level table finds, inherited ones included;
72
+ no option can shadow that.
73
+ - **A name spelled with symbol glyphs is read as the name.** The negative circled letters
74
+ (`U+1F150`..), the negative squared letters (`U+1F170`..) and the regional indicators (`U+1F1E6`..)
75
+ have no compatibility form, so the fold dropped them as punctuation and `🆃🅾🅺🅴🅽` folded to nothing
76
+ and kept its value in clear, at every depth, in a flat header array and as a property of an `Error`.
77
+ Each is now read as the Latin letter its Unicode name ends in. The table is generated from the
78
+ Unicode Character Database names (`scripts/generate-glyph-letters.mjs`, with a test that holds the
79
+ generated file to its input).
80
+ - **A key that only spells `stack` is written as a stack at the root of an entry too.** The message the
81
+ options hide is hidden in the header of a `Stack`, `STACK` or zero-width spelling of the stack of an
82
+ object message, as it is below the root, and in the same kind of own property of an `Error`.
83
+ - **The stack of a plain object is bounded whatever its message.** A message longer than the text limit
84
+ made the part of the stack that is searched as long as the message, and buffering one span for every
85
+ place a dense run matched cost memory out of proportion to the stack. A message longer than the text limit is no longer searched for:
86
+ the stack is written as the censor, as it is for more than eight messages, and a run of overlapping
87
+ matches is one span again.
88
+ - **A symbol that is not ASCII stands for a letter in a key.** A copyright sign, a sound recording sign,
89
+ a multiplication sign or any other symbol of the categories `So`, `Sm` and `Sk` was dropped as
90
+ punctuation, so `℗assword`, `©ookie` and `tok℮n` kept their value in clear. Each now stands for nothing,
91
+ one or two characters of a name, where a value is hidden, which hides the value of those keys and of a
92
+ short key that holds such a symbol (over-hiding is the price, as for a letter of another script). Dashes
93
+ and spaces are still dropped, and the keys the entry owns are still compared exactly.
94
+ - **An own enumerable `stack` of an `Error` is written as a stack.** The message the options hide is hidden
95
+ in it like in any key that spells `stack`.
96
+ - **The stack keys at the root of an entry are capped like those below it,** and the positional stack of
97
+ `error(object, stack)` has the message hidden: it was attached after the message was hidden.
98
+
99
+ ### Changed
100
+
101
+ - **A `redactPaths` entry is at most 256 characters.** A longer one is refused at startup by the name
102
+ of the option and its index (`options.redactPaths[i] must be at most 256 characters`), without echoing
103
+ it, where earlier releases accepted it and the application started. This holds for every strategy.
104
+ **Apply to a consumer:** an
105
+ entry over 256 characters now refuses boot; shorten it.
106
+
107
+ ## [1.4.29] - 2026-11-21
108
+
109
+ ### Fixed
110
+
111
+ - **Only the key `message` is left to the serializer of `err`.** A field of the object under `err` that
112
+ only spells it (`Message`, a zero-width character inside it, a look-alike letter) is a field like any
113
+ other and is hidden when `message` is a name to hide.
114
+ - **A configured name hides a field however its key is spelled.** The names of `redactPaths`, the
115
+ default names and the leaves of a configured path were compared with a key by exact name, in lower
116
+ case, so a field spelled with a zero-width character, a soft hyphen, a byte order mark, fullwidth
117
+ letters, a no-break space, a tab, a trailing space, a Cyrillic letter, a combining mark, a dotless
118
+ `i` or a separator (`api_key`, `api.Key`) was written in clear under `redactStrategy: 'names'`. Both
119
+ sides are now folded with the folding the library's own keys use (separators folded too), also for the
120
+ header names of a flat `rawHeaders` array. A name that is another word (`apiKeys` for `apiKey`) is
121
+ still another name. Every character that is not a letter or a digit is dropped from both sides (so
122
+ `x\u2011api\u2011key`, `access\u2010token`, `api\u2212key` and `pass:word` are `xapikey`, `accesstoken`, `apikey`
123
+ and `password`), and every letter that is not ASCII and that the look-alike list does not read as one Latin letter
124
+ stands for one or for two letters of a name (`ß`, `ꜷ` and `ꝏ` are two; a capital Cyrillic or Greek i,
125
+ drawn like an `I` and an `l`, is one): a key with such letters is hidden by any name it matches
126
+ everywhere else, which can hide the value of a key that only shares a name's ASCII letters and a
127
+ compatible length. The rule holds for a key made only of letters of another script too, as long as it
128
+ is no longer than the longest name: a spelling of `token` in Cyrillic and Armenian letters is hidden,
129
+ and so is a short field written in words of another script, which is the price of never letting a
130
+ spelling through. A key longer than every name is never taken for one (a configured name written in
131
+ that script still matches itself exactly), and a key with more candidate names of a compatible length
132
+ than a bound is hidden without being compared. This is for hiding a value only: the keys the entry owns, the keys
133
+ its derived fields use and the keys of the mixin are compared exactly after folding, so a caller
134
+ field written with such letters is not dropped for resembling one of them. Under `redactStrategy: 'paths'` the paths are matched exactly by `fast-redact`
135
+ and are not folded.
136
+ - **The stack header is hidden against every key that spells `message` or `stack`.** An object with
137
+ `{ message: 'x', Message: secret, stack: 'Error: secret' }`, or a `stack` beside a `Stack`, kept the
138
+ secret in a header: only the first key that spelled the name was read. Every one is read, once, and
139
+ every distinct text is hidden in every stack, longest first. The 1.4.27 line "whatever the case or
140
+ the look of the two keys" held for a single key of each name only.
141
+ - **More characters that print as nothing, and more letters and dots drawn like another, are read
142
+ through:** the Hangul fillers and the blank Braille pattern, the characters drawn like a full stop
143
+ (`U+3002`, `U+00B7`, `U+22C5` and others) and a few more letters drawn like a Latin one, in the
144
+ comparison of the derived keys, of the owned keys and of the configured names. The list of drawn
145
+ letters is a list, not every look-alike Unicode has.
146
+ - **A message the options hide is hidden wherever a stack repeats it.** Only the header of a stack was
147
+ rewritten, so a library that appends `Caused by: Error: <message>` left the text readable in the first
148
+ 16 KiB of `err.stack`, of the stack of a cause and of `exception.stacktrace`. Every occurrence of the
149
+ message in the part of the stack that is read is replaced now, for an `Error`, an `Error` whose name is
150
+ not text, a cause and an object that is no `Error`. A message short enough to appear in a frame is
151
+ replaced there too.
152
+ - **The `stack` of an object that is no `Error` is bounded and scrubbed at any depth.** A nested plain
153
+ object with a `stack` was written whole, up to its full length and with its dependency frames and
154
+ control characters. It is read up to the same bound as the stack of an error, written without
155
+ `node_modules` frames and with control characters escaped, and cut at the text limit with the suffix.
156
+ The name and the message of such an object are still written as given.
157
+ - **The search for hidden messages in the stacks of one object is bounded.** An object with more than
158
+ eight distinct messages under keys that spell `message`, or more than eight keys that spell `stack`,
159
+ has every stack written as the censor instead of searched, so a payload of thousands of look-alike
160
+ keys cannot stall the event loop.
161
+ - **A list option whose length is not a count is refused.** A Proxy that reports `-1`, `NaN`, `1.5` or
162
+ an infinite length was read as empty; it is refused by the name of the option.
163
+ - **A list option is capped at 10,000 entries.** `redactPaths`, `errorOwnFieldNames`, `destinations`,
164
+ `http.excludePaths` and `http.secretPathSegments` longer than that are refused at startup, by the
165
+ name of the option, before an element is read; a length a host reports as a billion no longer
166
+ allocates.
167
+
15
168
  ## [1.4.28] - 2026-11-21
16
169
 
17
170
  ### Fixed
@@ -3408,7 +3561,9 @@ published `dist/` is identical — no runtime behaviour changes for consumers.
3408
3561
  - Professional CI suite: `ci.yml`, `bench.yml`, `codeql.yml`, `scorecard.yml`,
3409
3562
  `release.yml`, Dependabot, and issue templates
3410
3563
 
3411
- [Unreleased]: https://github.com/bymaxone/nest-logger/compare/v1.4.28...HEAD
3564
+ [Unreleased]: https://github.com/bymaxone/nest-logger/compare/v1.4.30...HEAD
3565
+ [1.4.30]: https://github.com/bymaxone/nest-logger/compare/v1.4.29...v1.4.30
3566
+ [1.4.29]: https://github.com/bymaxone/nest-logger/compare/v1.4.28...v1.4.29
3412
3567
  [1.4.28]: https://github.com/bymaxone/nest-logger/compare/v1.4.27...v1.4.28
3413
3568
  [1.4.27]: https://github.com/bymaxone/nest-logger/compare/v1.4.26...v1.4.27
3414
3569
  [1.4.26]: https://github.com/bymaxone/nest-logger/compare/v1.4.25...v1.4.26
package/README.md CHANGED
@@ -879,7 +879,7 @@ The library censors **62 sensitive field names** wherever they appear in a recor
879
879
  | 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` |
880
880
  | 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 |
881
881
 
882
- Redaction is one **recursive, snapshotting walk**: a value is censored when its key name is in the set, wherever it sits. 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.
882
+ 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.
883
883
 
884
884
  > [!NOTE]
885
885
  > 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).
@@ -964,6 +964,10 @@ logger.warnStructured('AUTH_REUSE_DETECTED', 'token family revoked after reuse d
964
964
 
965
965
  An interpolated value has no name, so no configuration can redact it. **A value that matters is a field, not text.** A field can be redacted, queried and correlated; inside `msg` it can only be read by a human. The library cannot enforce this, because the decision is made at the call site.
966
966
 
967
+ **A key planted on `Object.prototype` is no option.** The options are read as you set them: a value that only the root of a prototype chain holds is skipped, so a pollution cannot turn default redaction off or change the censor. One limit stays, and it is Pino's: a key planted by plain assignment (so it is enumerable) under `level`, `levels`, `msgPrefix` or `levelVal` makes Pino throw: under `level`, `msgPrefix` or `levelVal` (which is read-only) **while the logger is built**, at startup, and under `levels` at the first call of the Nest-style methods (`log`, `warn`, `error`...), because Pino assigns every key a `for...in` over its level table finds to its instance. Others are Pino's and Node's own: a `hasOwnProperty` planted as something that is not a function makes Pino throw while it is built, and so does a `message` that is not a function, which Node's event emitter reaches through the destination streams. All of them fail loudly, write nothing and un-redact nothing. A built-in that the redaction reads and that a program replaces after the import drops the record, and redacts a URL path whole: before each record each one in the table (`GUARDED_BUILTINS` in `src/server/utils/captured-builtins.util.ts`, which a spec holds to the calls of `fold-key`, `normalize-url`, `matches-exclude-path`, `sanitize-error` and `pino-factory`) is compared with the one the module loaded with, and a logger is not built, nor its options resolved, while one differs. The table does not cover what `redact-by-name`, the error-text exemption, `redact-error-parts`, the mixin merge, the truncation and `bounded-text` call (`Object.assign`, `Function.prototype.call`, `Set.prototype.delete`, `charCodeAt`...); a program that replaces those can make a log call throw into the host, and none was found to let a value through. A value whose prototype chain does not end within the bound in `resolve-to-json.util.ts` is written as the censor. An error stack fails closed too, since the message would stay in its first line. What a program replaced **before** it imported the logger is what the logger loads with, and is outside the guard. The guard is against a pollution done by assignment, which plants data; a getter or a setter installed with `Object.defineProperty`, and a property made read-only, are outside it.
968
+
969
+ These guards are best-effort hardening against prototype pollution and replaced built-ins, not a security boundary: code running inside the host process is trusted, as in Node's own threat model. See [SECURITY.md](./SECURITY.md#threat-model-same-process-code).
970
+
967
971
  ### A closed pipe does not kill the process
968
972
 
969
973
  `node app | head` closes the read end of stdout while the application is still writing. Node reports the `EPIPE` asynchronously through the stream's `'error'` event, after `write()` returned, and attaches no default handler to `process.stdout`, so the emit becomes an uncaught exception and the process dies. Every write the library makes to a process stream (default stdout sink, last-resort rescue, pre-init drain, `stderr` reports) installs a swallowing `'error'` listener on first use. The one exception is the stream `pino-pretty` writes through, which attaches listeners of its own. The side effect: the listener sits on the shared `process.stdout`, so an EPIPE raised by your own writes stops being an uncaught exception too. Your own `'error'` listener is never removed or replaced. A custom `ILogDestination` that writes to `process.stdout` should do the same; the [destinations guide](./docs/guidelines/DESTINATIONS-IMPLEMENTATION-GUIDELINES.md) has the pattern.
@@ -1066,7 +1070,7 @@ Implements NestJS `LoggerService`. All methods are available via `@InjectLogger(
1066
1070
  | `fatal` | `(message, ...optionalParams)` | → Pino `fatal` |
1067
1071
  | `error` | `(message \| Error, stack?, context?)` | An `Error` routes to the serialized `err` path |
1068
1072
 
1069
- **An object as the message.** A plain object (an object literal or a parsed JSON object) passed as the message of `log`, `warn`, `error`, `debug`, `verbose` or `fatal` is written as the fields of the entry, through the same redaction and `maxStringLength` pipeline as any other field, so `this.logger.warn({ event: 'QUEUE_DRAINED', jobs: 7, password })` gives an entry with `event`, `jobs` and a censored `password`. The entry text (`msg`) is its `message` string, else its `event` string, else empty; a `message` that is the text is not repeated as a field. `logKey`, `userId`, `context`, `level`, `time`, `msg`, `service`, `service.*`, `deployment` and `deployment.*` in the object are dropped, as they are from `meta`. The text is censored under the names of the field it came from (`event` or `message`), also with `redactStrategy: 'paths'`, and cut at `maxStringLength` like that field, within the 16 KiB cap that bounds every log message. A serializer keyed `event` or `message` shapes the field and not `msg`; redaction by name is what covers the text. An `Error`, and an object shaped like one (a string `name` and a string `message`), keep their own error-only path (the text of the entry is the `message`, censored under the name `message` as `err.message` is, and the same text is censored where it opens `err.stack`, the stack of each cause and `exception.stacktrace`, and in `exception.message`; like every log message it is capped at 16 KiB and not cut at `maxStringLength`), and a value that is not plain (a class instance, an array) is still written as its string form. An object that is no error to the library but carries a `message` and a `stack` that are text has the message hidden in the header of that `stack`, everything before its first frame, wherever the options hide `message`; the frames are the stack's own text, and this holds for such an object below the top level of the record as well. A `name` that is an object, an array or a function is hidden with the message, as it may carry anything, and a number `name` is kept. The keys the library owns (`exception.type`, `exception.message`, `exception.stacktrace`, `error.type`) are matched as they look in a viewer: the same key in another case, with white space, combining marks or zero-width characters inside it, in fullwidth letters, or with a letter of another script drawn like a Latin one is dropped too, while `errorType`, `exception_type`, `exceptionType` and `event.name` are other keys and are kept. An object whose `toJSON` returns a `message` that is not text and a `stack` carrying a secret that is not the message text leaves nothing to match, so name such a secret in `redactPaths`. Redaction works on field names and never reads the content of a string, so a text a caller passes as a string, such as ``logger.warn(`card ${number}`)``, is written as it is.
1073
+ **An object as the message.** A plain object (an object literal or a parsed JSON object) passed as the message of `log`, `warn`, `error`, `debug`, `verbose` or `fatal` is written as the fields of the entry, through the same redaction and `maxStringLength` pipeline as any other field, so `this.logger.warn({ event: 'QUEUE_DRAINED', jobs: 7, password })` gives an entry with `event`, `jobs` and a censored `password`. The entry text (`msg`) is its `message` string, else its `event` string, else empty; a `message` that is the text is not repeated as a field. `logKey`, `userId`, `context`, `level`, `time`, `msg`, `service`, `service.*`, `deployment` and `deployment.*` in the object are dropped, as they are from `meta`. The text is censored under the names of the field it came from (`event` or `message`), also with `redactStrategy: 'paths'`, and cut at `maxStringLength` like that field, within the 16 KiB cap that bounds every log message. A serializer keyed `event` or `message` shapes the field and not `msg`; redaction by name is what covers the text. An `Error`, and an object shaped like one (a string `name` and a string `message`), keep their own error-only path (the text of the entry is the `message`, censored under the name `message` as `err.message` is, and the same text is censored where it opens `err.stack`, the stack of each cause and `exception.stacktrace`, and in `exception.message`; like every log message it is capped at 16 KiB and not cut at `maxStringLength`), and a value that is not plain (a class instance, an array) is still written as its string form. An object that is no error to the library but carries a `message` and a `stack` that are text has the message hidden in the header of that `stack`, everything before its first frame, wherever the options hide `message`; the message is hidden wherever the stack repeats it (a `Caused by:` line, a frame), within the part of the stack that is read, and this holds for such an object below the top level of the record as well. The `stack` of any object that is no `Error`, at any depth, is written like the stack of an error: without dependency frames, with control characters escaped and cut at the text limit. An object with more than eight distinct messages under keys that spell `message`, or more than eight keys that spell `stack`, has every stack written as the censor. A `name` that is an object, an array or a function is hidden with the message, as it may carry anything, and a number `name` is kept. The keys the library owns (`exception.type`, `exception.message`, `exception.stacktrace`, `error.type`) are matched as they look in a viewer: the same key in another case, with white space, combining marks, zero-width characters or characters that print as nothing inside it, in fullwidth letters, or with a letter of another script drawn like a Latin one is dropped too, while `errorType`, `exception_type`, `exceptionType` and `event.name` are other keys and are kept. An object whose `toJSON` returns a `message` that is not text and a `stack` carrying a secret that is not the message text leaves nothing to match, so name such a secret in `redactPaths`. Redaction works on field names and never reads the content of a string, so a text a caller passes as a string, such as ``logger.warn(`card ${number}`)``, is written as it is.
1070
1074
 
1071
1075
  **Helpers**
1072
1076
 
@@ -1237,18 +1241,20 @@ Two kinds of failure, and they surface differently. A **thrown `Error`** carries
1237
1241
 
1238
1242
  ### Thrown errors
1239
1243
 
1240
- | Message starts with | Thrown from | When | Action |
1241
- | -------------------------------------------------------- | ------------------------------------------- | --------------------------------------------------------------------------------------- | ------------------------------------------------------------------------- |
1242
- | `[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 |
1243
- | `[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` |
1244
- | `[BymaxLoggerModule] useNestLogger(app) called but` | `BymaxLoggerModule.useNestLogger` | the module was never imported into the application | Import `BymaxLoggerModule` before calling it |
1245
- | `[BymaxLoggerModule] applyAccessLog(app) called but` | `applyAccessLog` | the module was never imported into the application | Import `BymaxLoggerModule` before calling it |
1246
- | `[BymaxLoggerModule] useRequestContext(app) called but` | `useRequestContext` | the module was never imported into the application | Import `BymaxLoggerModule` before calling it |
1247
- | `[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 |
1248
- | `[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 |
1249
- | `[PrettyDevDestination] refused in production` | `PrettyDevDestination.onInit` | `NODE_ENV` is exactly `production` | Use `DefaultStdoutDestination` in production |
1250
- | `[LogContextService] set() called outside run() scope` | `LogContextService.set` | called with no active `run()` | Wrap the work in `logContext.run({ ... }, () => ...)` |
1251
- | `[LogContextService] Refusing to set unsafe context key` | `LogContextService.set` | the key is `__proto__`, `constructor` or `prototype` | Use an ordinary key |
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 |
1252
1258
 
1253
1259
  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.
1254
1260
 
@@ -15,6 +15,8 @@ var __decorateClass = (decorators, target, key, kind) => {
15
15
  return result;
16
16
  };
17
17
  var __decorateParam = (index, decorator) => (target, key) => decorator(target, key, index);
18
+ var IntrinsicPromise = Object.getPrototypeOf((async () => void 0)()).constructor;
19
+ var define = Object.defineProperty;
18
20
  var LOGGER_HEALTH_INDICATOR_NAME = "logger";
19
21
  exports.LoggerHealthIndicator = class LoggerHealthIndicator {
20
22
  /**
@@ -31,10 +33,21 @@ exports.LoggerHealthIndicator = class LoggerHealthIndicator {
31
33
  */
32
34
  check() {
33
35
  const { destinations, failedInit, writeFailing, hasHealthySink } = this.observability.deliveryState();
34
- return Promise.resolve({
36
+ const verdict = Object.freeze({
37
+ __proto__: null,
35
38
  status: hasHealthySink ? "up" : "down",
36
- details: { destinations, failedInit, writeFailing }
39
+ details: Object.freeze({ destinations, failedInit, writeFailing })
37
40
  });
41
+ const answer = new IntrinsicPromise((resolve) => {
42
+ resolve(verdict);
43
+ });
44
+ define(answer, "constructor", {
45
+ __proto__: null,
46
+ value: IntrinsicPromise,
47
+ writable: false,
48
+ configurable: false
49
+ });
50
+ return answer;
38
51
  }
39
52
  };
40
53
  exports.LoggerHealthIndicator = __decorateClass([
@@ -13,6 +13,8 @@ var __decorateClass = (decorators, target, key, kind) => {
13
13
  return result;
14
14
  };
15
15
  var __decorateParam = (index, decorator) => (target, key) => decorator(target, key, index);
16
+ var IntrinsicPromise = Object.getPrototypeOf((async () => void 0)()).constructor;
17
+ var define = Object.defineProperty;
16
18
  var LOGGER_HEALTH_INDICATOR_NAME = "logger";
17
19
  var LoggerHealthIndicator = class {
18
20
  /**
@@ -29,10 +31,21 @@ var LoggerHealthIndicator = class {
29
31
  */
30
32
  check() {
31
33
  const { destinations, failedInit, writeFailing, hasHealthySink } = this.observability.deliveryState();
32
- return Promise.resolve({
34
+ const verdict = Object.freeze({
35
+ __proto__: null,
33
36
  status: hasHealthySink ? "up" : "down",
34
- details: { destinations, failedInit, writeFailing }
37
+ details: Object.freeze({ destinations, failedInit, writeFailing })
35
38
  });
39
+ const answer = new IntrinsicPromise((resolve) => {
40
+ resolve(verdict);
41
+ });
42
+ define(answer, "constructor", {
43
+ __proto__: null,
44
+ value: IntrinsicPromise,
45
+ writable: false,
46
+ configurable: false
47
+ });
48
+ return answer;
36
49
  }
37
50
  };
38
51
  LoggerHealthIndicator = __decorateClass([