@bymax-one/nest-logger 1.4.11 → 1.4.13
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 +70 -1
- package/README.md +16 -0
- package/dist/server/index.cjs +652 -527
- package/dist/server/index.d.cts +46 -2
- package/dist/server/index.d.ts +46 -2
- package/dist/server/index.mjs +652 -527
- package/package.json +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -11,6 +11,73 @@ heading here.
|
|
|
11
11
|
|
|
12
12
|
## [Unreleased]
|
|
13
13
|
|
|
14
|
+
## [1.4.13] - 2026-11-08
|
|
15
|
+
|
|
16
|
+
### Fixed
|
|
17
|
+
|
|
18
|
+
- **A client error the body parser raises keeps its status.** An error with the `http-errors` shape,
|
|
19
|
+
a `status` or `statusCode` from 400 to 499 and `expose: true`, such as a body over the limit
|
|
20
|
+
(413) or an unsupported content encoding (415), was answered by `HttpExceptionFilter` as a 500
|
|
21
|
+
`{ statusCode, message }`. That filter is registered by `forRoot` with `http.isEnabled` and
|
|
22
|
+
`http.shouldCaptureExceptions` (default `true`), or by hand; `forRootAsync` does not register it, and an application that uses it without the filter was
|
|
23
|
+
answered by Nest's own handler, with the right status, before and after. It is now answered
|
|
24
|
+
with its own status and message, `{ statusCode: 413, message: 'request entity too large' }`, and
|
|
25
|
+
logged as `HTTP_EXCEPTION_HANDLED` at warn level. The same error thrown inside a route is no
|
|
26
|
+
longer logged as `HTTP_REQUEST_SERVER_ERROR` but as `HTTP_REQUEST_CLIENT_ERROR`. An error
|
|
27
|
+
without `expose: true`, or with a status outside 400 to 499, stays a 500 with the fixed body.
|
|
28
|
+
**Apply to a derived backend:** nothing to do; a client that read the 500 for these cases now
|
|
29
|
+
reads the 413 or 415 the parser meant.
|
|
30
|
+
- **The README says which filter answers a parser error, and for whom.** `forRoot` with
|
|
31
|
+
`http.isEnabled` and `http.shouldCaptureExceptions` (default `true`) registers the library's own
|
|
32
|
+
exception filter as an `APP_FILTER` provider, so the
|
|
33
|
+
import order of the modules decides between `APP_FILTER` providers, and `app.useGlobalFilters(...)`
|
|
34
|
+
always answers ahead of them. `forRootAsync` registers no filter, so none of that applies to it
|
|
35
|
+
unless the filter is registered by hand. The 1.4.12 note on this was written without that scope.
|
|
36
|
+
Pinned by `use-request-context-filters.e2e-spec.ts`.
|
|
37
|
+
|
|
38
|
+
### Internal
|
|
39
|
+
|
|
40
|
+
- **A source file over 800 lines now fails CI unless it is on a frozen baseline.**
|
|
41
|
+
`scripts/check-file-length.mjs` (`pnpm check:file-length`) runs in the `verify` job and, in a
|
|
42
|
+
pull request, also compares the baseline with the base branch's, so the baseline cannot widen. It
|
|
43
|
+
starts with the three files that are already over the limit. Nothing in the package changes.
|
|
44
|
+
- **The redaction walk is split into functions of at most 50 lines.** `walkObject` was 174 lines;
|
|
45
|
+
it is now a short function that delegates to smaller ones, with the rationale kept as their
|
|
46
|
+
documentation. No behaviour changes: 48000 comparisons of the old and the new walk over
|
|
47
|
+
generated records (six configurations, as record root and not), and the existing suite, give
|
|
48
|
+
identical output.
|
|
49
|
+
|
|
50
|
+
## [1.4.12] - 2026-11-08
|
|
51
|
+
|
|
52
|
+
### Added
|
|
53
|
+
|
|
54
|
+
- **`BymaxLoggerModule.useRequestContext(app)`.** Opens the request-id correlation scope ahead of
|
|
55
|
+
the body parser, from `main.ts`, like `useNestLogger(app)`. A request the parser refuses
|
|
56
|
+
(truncated JSON, an unsupported content encoding, a body over the limit) now has its `requestId`
|
|
57
|
+
and the `x-request-id` response header, so a consumer's exception filter that reads the id from
|
|
58
|
+
`LogContextService` writes the same value in its envelope. It mounts only the scope and can be
|
|
59
|
+
combined with `applyAccessLog(app)` or `applyRequestIdMiddleware(consumer)`. Additive: nothing
|
|
60
|
+
changes for an application that does not call it.
|
|
61
|
+
|
|
62
|
+
### Changed
|
|
63
|
+
|
|
64
|
+
- **1.4.11 behaviour its notes did not list.** Under `errorOwnFields: 'all'` with
|
|
65
|
+
`redactStrategy: 'paths'`, an `Error` whose `toJSON` is a hostile accessor has been written as
|
|
66
|
+
`UnknownError` since 1.4.11, as `redactStrategy: 'names'` already did; 1.4.10 wrote it as an
|
|
67
|
+
`Error`. Nothing changes here; this records it.
|
|
68
|
+
|
|
69
|
+
#### Apply to a derived backend
|
|
70
|
+
|
|
71
|
+
Nothing is required: `BymaxLoggerModule.useRequestContext(app)` is a new static method and an
|
|
72
|
+
application that does not call it behaves as before. To have a request the body parser refuses
|
|
73
|
+
(truncated JSON, an unsupported content encoding, a body over the limit) carry its `requestId` and
|
|
74
|
+
the `x-request-id` response header, call it in `main.ts` right after `NestFactory.create()` and
|
|
75
|
+
before `app.init()` / `app.listen()`. Register the filter that writes the id into your envelope with `app.useGlobalFilters(...)` after
|
|
76
|
+
`NestFactory.create()`: with `http.isEnabled` (and `http.shouldCaptureExceptions`, which defaults to `true`) the library registers its own exception filter as an
|
|
77
|
+
`APP_FILTER` provider, and an `APP_FILTER` provider of yours was answered by it in the measurement,
|
|
78
|
+
with or without an injected dependency, while a filter registered with `useGlobalFilters` answered
|
|
79
|
+
instead.
|
|
80
|
+
|
|
14
81
|
## [1.4.11] - 2026-11-08
|
|
15
82
|
|
|
16
83
|
### Added
|
|
@@ -2516,7 +2583,9 @@ published `dist/` is identical — no runtime behaviour changes for consumers.
|
|
|
2516
2583
|
- Professional CI suite: `ci.yml`, `bench.yml`, `codeql.yml`, `scorecard.yml`,
|
|
2517
2584
|
`release.yml`, Dependabot, and issue templates
|
|
2518
2585
|
|
|
2519
|
-
[Unreleased]: https://github.com/bymaxone/nest-logger/compare/v1.4.
|
|
2586
|
+
[Unreleased]: https://github.com/bymaxone/nest-logger/compare/v1.4.13...HEAD
|
|
2587
|
+
[1.4.13]: https://github.com/bymaxone/nest-logger/compare/v1.4.12...v1.4.13
|
|
2588
|
+
[1.4.12]: https://github.com/bymaxone/nest-logger/compare/v1.4.11...v1.4.12
|
|
2520
2589
|
[1.4.11]: https://github.com/bymaxone/nest-logger/compare/v1.4.10...v1.4.11
|
|
2521
2590
|
[1.4.10]: https://github.com/bymaxone/nest-logger/compare/v1.4.9...v1.4.10
|
|
2522
2591
|
[1.4.9]: https://github.com/bymaxone/nest-logger/compare/v1.4.8...v1.4.9
|
package/README.md
CHANGED
|
@@ -447,6 +447,21 @@ reading `statusCode` and `writableFinished`, so it never depends on a route matc
|
|
|
447
447
|
running or a filter catching anything. One line in, one line out, for the parser rejection, the
|
|
448
448
|
unmatched-route 404, the guard rejection and the aborted connection alike.
|
|
449
449
|
|
|
450
|
+
To open only the correlation scope ahead of the parser, without the access log, call
|
|
451
|
+
`BymaxLoggerModule.useRequestContext(app)` at the same point. A request the parser refuses (truncated JSON,
|
|
452
|
+
a content encoding it does not support, a body over the limit) then has its `requestId` and the
|
|
453
|
+
`x-request-id` response header, so an exception filter that reads the id from `LogContextService`
|
|
454
|
+
puts the same value in its envelope. Register that filter with `app.useGlobalFilters(...)` after `NestFactory.create()`, which answers
|
|
455
|
+
ahead of every `APP_FILTER` provider. `forRoot` with `http.isEnabled` (and
|
|
456
|
+
`http.shouldCaptureExceptions`, which defaults to `true`) registers the library's own exception
|
|
457
|
+
filter as an `APP_FILTER` provider; `forRootAsync` never does, so there is nothing for yours to
|
|
458
|
+
compete with unless you registered `HttpExceptionFilter` yourself. Where the library's filter is
|
|
459
|
+
registered, the order the modules are imported decides between `APP_FILTER` providers: one in your
|
|
460
|
+
root module, or in a module imported before `BymaxLoggerModule`, was answered by the library's
|
|
461
|
+
filter in the measurement, with or without an injected dependency, while one in a module imported
|
|
462
|
+
after it answered itself. It can be combined with `applyAccessLog(app)` or
|
|
463
|
+
`applyRequestIdMiddleware(consumer)`: a second mount reuses the scope.
|
|
464
|
+
|
|
450
465
|
`applyRequestIdMiddleware(consumer)` remains supported and unchanged; it is the right choice when
|
|
451
466
|
correlation should be scoped to a route subtree rather than the whole application. **Wiring both is
|
|
452
467
|
safe** — the correlation middleware adopts an id already in scope instead of minting a second one,
|
|
@@ -1610,6 +1625,7 @@ Two kinds of failure, and they surface differently. A **thrown `Error`** carries
|
|
|
1610
1625
|
| `[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 |
|
|
1611
1626
|
| `[BymaxLoggerModule] useNestLogger(app) called but` | `BymaxLoggerModule.useNestLogger` | the module was never imported into the application | Import `BymaxLoggerModule` before calling it |
|
|
1612
1627
|
| `[BymaxLoggerModule] applyAccessLog(app) called but` | `applyAccessLog` | the module was never imported into the application | Import `BymaxLoggerModule` before calling it |
|
|
1628
|
+
| `[BymaxLoggerModule] useRequestContext(app) called but` | `useRequestContext` | the module was never imported into the application | Import `BymaxLoggerModule` before calling it |
|
|
1613
1629
|
| `[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 |
|
|
1614
1630
|
| `[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 |
|
|
1615
1631
|
| `[PrettyDevDestination] refused in production` | `PrettyDevDestination.onInit` | `NODE_ENV` is exactly `production` | Use `DefaultStdoutDestination` in production |
|