@bymax-one/nest-logger 1.4.2 → 1.4.4

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
@@ -11,6 +11,137 @@ heading here.
11
11
 
12
12
  ## [Unreleased]
13
13
 
14
+ ## [1.4.4] - 2026-11-01
15
+
16
+ ### Documentation
17
+
18
+ - The Quick Start's "Output (JSON, production)" sample is now exactly what the flow prints:
19
+ it gains `deployment`, `userId` and `event.name`, and its version matches the snippet. The
20
+ request and trace fields (`requestId`, `tenantId`, `traceId`, `spanId`) are no longer in it, since
21
+ they are absent outside an HTTP request and an active span; a sentence says when they appear.
22
+
23
+ ### Tests
24
+
25
+ - A unit test executes the README Quick Start (sections 2 and 4) as written and asserts the JSON
26
+ lines it logs. `check:published` only type-checks the snippets; this one runs them. It also
27
+ requires the README's "Output (JSON, production)" sample to have the same keys as the real line.
28
+
29
+ ## [1.4.3] - 2026-10-31
30
+
31
+ ### Added
32
+
33
+ - `LOGGER_REDACTOR_TOKEN`, `REDACT_COMMON_FIELDS` and `isValidTraceId` are exported from the package
34
+ root. The token is the injection point of `PinoLoggerService`'s redactor, so a consumer composing
35
+ its own providers can now name it. `REDACT_COMMON_FIELDS` is the name list the
36
+ default redactor matches, and `DEFAULT_REDACT_PATHS` is built from it, so extending the defaults no
37
+ longer means copying the names. `isValidTraceId` is the check the trace mixin already applies.
38
+ `sanitizeError` stays internal: its output shape is not a contract this release commits to.
39
+
40
+ ### Deprecated
41
+
42
+ - `@LogContext(name)` is marked `@deprecated`. It records a label as class metadata and nothing in
43
+ the package reads it, so the label has never been applied. `@InjectLogger(MyClass.name)` is the
44
+ working equivalent. `shouldUseAsNestLogger` was already deprecated and is unchanged.
45
+
46
+ ### Fixed
47
+
48
+ - **A custom `timestamp` can no longer break the log line or add fields to it.** Pino inserts the
49
+ value into the JSON line verbatim, and the library wrapped it in quotes without encoding it, so a
50
+ quote, a backslash or a newline in the returned string produced invalid JSON for every entry, and a
51
+ crafted value such as `","injected":"x` added a field. The value is now encoded as a JSON string,
52
+ and `time` carries exactly what the function returned.
53
+
54
+ ### Breaking
55
+
56
+ - **`http.excludePaths` now excludes `/health/live` and `/health/ready` by default**, the probes of
57
+ `@bymax-one/nest-core`, so the defaults are `/health`, `/health/live`, `/health/ready` and
58
+ `/metrics`. A probe hit every few seconds drowned the record (8272 of 8274 entries on one
59
+ deployment). Each default is an exact, anchored path, so a route such as `/health/other` is still
60
+ logged.
61
+ - **Options are validated more strictly at bootstrap**, each rejection naming the option and, where
62
+ there is a value to show, what was received. Added checks: `maxEntrySizeBytes` must be a finite number (a `NaN` or `Infinity`
63
+ made the size gate never trip); `isGlobal`, `shouldDisableDefaultRedact` and the `http` and `otel`
64
+ switches must be booleans (the string `'false'` is truthy); `redactCensor` a string; `timestamp` a
65
+ function; `redactPaths` an array of non-empty strings; `serializers` an object of functions;
66
+ `destinations` an array whose entries have a `write` method, a non-empty `name` and function hooks;
67
+ `http` and `otel` objects; `http.excludePaths` an array of `RegExp` (a pattern from another realm,
68
+ such as a `vm` context, is accepted); `http.tenantIdHeader` and the
69
+ three `otel.*Field` names non-empty strings; `otel.fieldFormat` `'camelCase'` or `'snake_case'`
70
+ (an unknown value silently behaved as `camelCase`).
71
+ - **`PrettyDevDestination` refuses to initialize when `NODE_ENV` is `production`.** The 0.1.0 entry
72
+ said it was auto-disabled in production, and nothing did that: registered there it rendered ANSI
73
+ colour through a main-thread transform into the log stream. It now fails at `onInit()` with a
74
+ message naming the cause; the registry reports `LOGGER_DESTINATION_INIT_FAILED` on stderr, later
75
+ writes to it are dropped, and when it is the only destination entries go to stdout as raw NDJSON.
76
+ Only the exact value `production` refuses.
77
+
78
+ #### Apply to a consumer
79
+
80
+ - A deployment whose own `/health/live` or `/health/ready` route should stay in the log now sets
81
+ `http.excludePaths` itself. A value replaces the defaults, and `[/^\/health$/, /^\/metrics$/]`
82
+ restores the previous list.
83
+ - An application that passed a value of the wrong kind, such as `http: { isEnabled: 'false' }` or a
84
+ destination without a `name`, now fails at bootstrap with a message naming the option, where it
85
+ previously booted with that value ignored or misread. Correct the value.
86
+ - A deployment that registers `PrettyDevDestination` with `NODE_ENV=production` now gets raw JSON on
87
+ stdout and one stderr line instead of coloured output. Register it only outside production, for
88
+ example `...(process.env.NODE_ENV === 'production' ? [] : [new PrettyDevDestination()])`, and keep
89
+ `DefaultStdoutDestination` in the list.
90
+
91
+ ### Documentation
92
+
93
+ - The error catalog listed codes that nothing in the library emits (for example
94
+ `LOGGER_INVALID_OPTIONS` and `LOGGER_OTEL_API_UNAVAILABLE`), and described them as thrown. A thrown
95
+ error carries a message, not a code, so the catalog now separates the message each thrown error
96
+ starts with from the log keys the library writes. It also gains the errors it omitted and the real
97
+ surface of a missing `@opentelemetry/api`, a `LOGGER_BOOTSTRAP_WARNING` with
98
+ `reason: 'OTEL_API_UNAVAILABLE'`.
99
+ `readme-error-catalog.spec.ts` scans every throw site in `src` and fails when a row and the code
100
+ disagree in either direction.
101
+ - The README documents the injection tokens and the exported helpers, the `useClass` and
102
+ `useExisting` forms of `forRootAsync`, the rules the request-id middleware applies to an inbound
103
+ `x-request-id` and tenant header (a value that fails them is replaced, not cleaned), and that a
104
+ Fastify adapter is not supported.
105
+ - `forRootAsync` does not register the exception filter, which `forRoot` does, and the README now
106
+ says so under the async example, in the options table and in the `http` option JSDoc. Measured with
107
+ the same failing controller on both paths: with `http.isEnabled`, `forRootAsync` emits the access
108
+ log (`HTTP_REQUEST_START`, `_CLIENT_ERROR`, `_SERVER_ERROR`) and the real error reaches its terminal
109
+ entry, but not `HTTP_EXCEPTION_HANDLED` or `HTTP_EXCEPTION_UNHANDLED`; the 500 response is
110
+ identical. Registering `{ provide: APP_FILTER, useClass: HttpExceptionFilter }` yields them. The
111
+ difference is deliberate, and a spec pins the behaviour and the remedy.
112
+ - `ILogDestination` JSDoc: `write` no longer says a failing destination "may be temporarily
113
+ skipped". Nothing skips a destination that initialized: every failed entry is dropped for it and
114
+ reported, and it keeps receiving entries. Only one whose `onInit()` failed receives none.
115
+ `minLevel` says it can only narrow what the module `level` lets through.
116
+ - The README prose and tables are corrected against the code; that correction touches no source file.
117
+ - The options table gave `level` a default of `'info'`. Outside `NODE_ENV=production` the default
118
+ is `'debug'`. It now lists the options it omitted: `isGlobal`, `serializers`, `timestamp`, the
119
+ deprecated `shouldUseAsNestLogger`, and `otel.traceIdField`, `otel.spanIdField` and
120
+ `otel.traceFlagsField`.
121
+ - `DefaultStdoutDestination` was called "always active". It is the default sink only while
122
+ `destinations` is empty, as the Destinations section already said. A destination whose
123
+ `onInit()` rejects was described as staying in the write fan-out. It is removed from the fan-out
124
+ and from shutdown.
125
+ - The architecture diagram showed `info(logKey, msg, context, metadata)`; the third parameter is
126
+ `userId`. It named a `composedMixin()` that does not exist (the function is
127
+ `createTraceContextMixin`) and put `userId` in the scope `RequestIdMiddleware` opens, which holds
128
+ `requestId` and `tenantId`.
129
+ - The tech stack badges now read pnpm 11 and tsup 9. The URL normalization lists name ULID and
130
+ nanoid segments as well as UUID and numeric ones. The `LogContextService` table lists `get()`.
131
+ The last two HTTP log keys sit inside their table.
132
+ - The Pino throughput figures are attributed to Pino's own benchmarks, the `Scope.REQUEST` cost
133
+ to NestJS's estimate, and the EPIPE guard note names its one exception, `pino-pretty`'s own
134
+ stream.
135
+ - The resource identity example passed `process.env.POD_UID` to `service.instanceId`, which does
136
+ not compile under `exactOptionalPropertyTypes` because the value can be `undefined`. It now reads
137
+ `process.env.POD_UID!`.
138
+
139
+ ### Tests
140
+
141
+ - `readme-options.spec.ts` parses the three option tables in the README and checks every default
142
+ against the defaults the module applies, and checks that the tables list exactly the options the
143
+ module resolves, so a default that drifts, or an option added without a row, fails the suite.
144
+
14
145
  ## [1.4.2] - 2026-10-30
15
146
 
16
147
  No breaking changes. Dependency and build-tooling maintenance only. No source file under `src/` changes and the
@@ -2076,7 +2207,9 @@ published `dist/` is identical — no runtime behaviour changes for consumers.
2076
2207
  - Professional CI suite: `ci.yml`, `bench.yml`, `codeql.yml`, `scorecard.yml`,
2077
2208
  `release.yml`, Dependabot, and issue templates
2078
2209
 
2079
- [Unreleased]: https://github.com/bymaxone/nest-logger/compare/v1.4.2...HEAD
2210
+ [Unreleased]: https://github.com/bymaxone/nest-logger/compare/v1.4.4...HEAD
2211
+ [1.4.4]: https://github.com/bymaxone/nest-logger/compare/v1.4.3...v1.4.4
2212
+ [1.4.3]: https://github.com/bymaxone/nest-logger/compare/v1.4.2...v1.4.3
2080
2213
  [1.4.2]: https://github.com/bymaxone/nest-logger/compare/v1.4.1...v1.4.2
2081
2214
  [1.4.1]: https://github.com/bymaxone/nest-logger/compare/v1.4.0...v1.4.1
2082
2215
  [1.4.0]: https://github.com/bymaxone/nest-logger/compare/v1.3.1...v1.4.0