@bymax-one/nest-logger 1.4.30 → 1.4.31
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 +16 -1
- package/README.md +2 -2
- package/dist/server/index.cjs +30 -37
- package/dist/server/index.mjs +30 -37
- package/package.json +4 -3
package/CHANGELOG.md
CHANGED
|
@@ -12,6 +12,20 @@ heading here.
|
|
|
12
12
|
|
|
13
13
|
## [Unreleased]
|
|
14
14
|
|
|
15
|
+
## [1.4.31] - 2026-11-25
|
|
16
|
+
|
|
17
|
+
### Changed
|
|
18
|
+
|
|
19
|
+
Both were measured against 1.4.30. For the input a real caller produces, the output is the same.
|
|
20
|
+
|
|
21
|
+
- **Hiding a message longer than the stack it is searched in costs more time.** The message is now cut to one character more than the stack before it is searched, so the table the search builds is bounded by the stack. Measured per call with a message of 10,000,000 characters: 0.009 ms to 1.41 ms for a concatenated message, 0.001 ms to 0.225 ms for a repeated pattern.
|
|
22
|
+
- **`PinoUnexpectedErrorSink` reads `error.getResponse` once.** It was read once to check its type and again to call it. An accessor that answers differently on the second read now gets the fields of its first answer.
|
|
23
|
+
|
|
24
|
+
### Documentation
|
|
25
|
+
|
|
26
|
+
- **A body parser mounted after `app.init()` does not produce a parser entry; the README said it kept the parser's message.** Measured through `NestFactory` and real HTTP, with a malformed JSON body to a route: with Nest's default parser the answer is `400` and `HTTP_EXCEPTION_HANDLED` carries `bodyParserType: 'entity.parse.failed'`; with `express.json()` mounted after `app.init()`, and with no parser at all, the route runs with no parsed body (`201`) and no `HTTP_EXCEPTION_HANDLED` entry is written. Measured with the packed library in a scratch package, `@nestjs/platform-fastify` 11.2.9 and Fastify 5.12.8: the same malformed body answers `400` and `HTTP_EXCEPTION_HANDLED` carries Fastify's own message with no `bodyParserType`, and the response the filter writes fails with `res.status(...).json is not a function`. The Fastify adapter stays unsupported, so this is a documented limit (issue #211), not a gap to close. No code change.
|
|
27
|
+
- **`options.level` outside the Pino levels is refused.** Measured: `'verbose'`, `'silent'`, `'FATAL'` and the number `30` each make `forRoot` throw, and `'silent'` makes `forRootAsync` throw at bootstrap; the README did not say what happens to a value outside the levels. No code change.
|
|
28
|
+
|
|
15
29
|
## [1.4.30] - 2026-11-24
|
|
16
30
|
|
|
17
31
|
### Breaking
|
|
@@ -3561,7 +3575,8 @@ published `dist/` is identical — no runtime behaviour changes for consumers.
|
|
|
3561
3575
|
- Professional CI suite: `ci.yml`, `bench.yml`, `codeql.yml`, `scorecard.yml`,
|
|
3562
3576
|
`release.yml`, Dependabot, and issue templates
|
|
3563
3577
|
|
|
3564
|
-
[Unreleased]: https://github.com/bymaxone/nest-logger/compare/v1.4.
|
|
3578
|
+
[Unreleased]: https://github.com/bymaxone/nest-logger/compare/v1.4.31...HEAD
|
|
3579
|
+
[1.4.31]: https://github.com/bymaxone/nest-logger/compare/v1.4.30...v1.4.31
|
|
3565
3580
|
[1.4.30]: https://github.com/bymaxone/nest-logger/compare/v1.4.29...v1.4.30
|
|
3566
3581
|
[1.4.29]: https://github.com/bymaxone/nest-logger/compare/v1.4.28...v1.4.29
|
|
3567
3582
|
[1.4.28]: https://github.com/bymaxone/nest-logger/compare/v1.4.27...v1.4.28
|
package/README.md
CHANGED
|
@@ -270,7 +270,7 @@ A key that holds `undefined` or `null` is read as not set, in the options and in
|
|
|
270
270
|
| `resourceFormat` | `'nested' \| 'flat'` | `'nested'` | Shape of the identity fields. `'flat'` emits the dotted attribute names verbatim |
|
|
271
271
|
| `eventNameField` | `string \| false` | `'event.name'` | Field carrying the derived event name (`PAYMENT_FAILED` → `payment.failed`). `false` disables it |
|
|
272
272
|
| `errorFormat` | `'pino' \| 'semconv' \| 'both'` | `'pino'` | `'both'` adds `exception.*` and `error.type` beside `err.*`; `'semconv'` replaces them |
|
|
273
|
-
| `level` | `LogLevel` | `'info'` when `NODE_ENV=production`, else `'debug'` | Minimum log level. One of `fatal \| error \| warn \| info \| debug \| trace`
|
|
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
274
|
| `redactPaths` | `string[]` | `[]` | Additional `fast-redact` paths, applied on top of the default coverage |
|
|
275
275
|
| `redactStrategy` | `'names' \| 'paths'` | `'names'` | Engine behind the DEFAULT set. `'paths'` is the legacy `fast-redact` expansion (four-level ceiling, much slower) |
|
|
276
276
|
| `shouldDisableDefaultRedact` | `boolean` | `false` | Skip the default PII coverage entirely. ⚠️ Emits `LOGGER_BOOTSTRAP_WARNING` at startup — document why |
|
|
@@ -373,7 +373,7 @@ The levels are `info` for `HTTP_REQUEST_START`, `HTTP_REQUEST_SUCCESS` and `HTTP
|
|
|
373
373
|
|
|
374
374
|
URLs are normalized (`/users/550e8400-e29b-41d4-a716-446655440000` becomes `/users/:id`) so label cardinality stays bounded. The **query string is stripped** from every logged URL and from the message of a logged exception, because a magic-link token in a query parameter is a secret no key-name redaction can scrub out of a string. Only a literal `?` starts a query. A path segment that looks like a credential (a long hex value, a JWT, an opaque token, an email address, or a dotted token such as `ya29.…` or `v4.local.…` of which any dot-separated part is a long opaque token) is written as `:redacted` in `url`, `fullUrl` and the not-found message, and `http.secretPathSegments` adds your own patterns. `fullUrl` is the raw path without its query and with those segments replaced, not the request as received. A long camelCase or Pascal-case name cannot be told from a token and is replaced too. A secret the rules cannot see, such as `;jsessionid=...` in a segment, stays in `url`, and the message of a 5xx error is the application's own text, which is not scrubbed.
|
|
375
375
|
|
|
376
|
-
For a body that does not parse (`entity.parse.failed`), one the parser's `verify` refuses (`entity.verify.failed`), or an unsupported content encoding or charset, `HTTP_EXCEPTION_HANDLED` carries a fixed message and the parser `type` in `bodyParserType`, because the parser's message can quote part of the body. While `HttpExceptionFilter` is registered it also writes the response: an `HttpException` keeps its own body, a thrown value that exposes a 4xx status becomes `{ statusCode, message }`, and any other error becomes `500 { statusCode: 500, message: 'Internal server error' }`; the application owns the response only when it registers no such filter. The malformed-JSON case needs the Express adapter and a body parser mounted before `app.init()`, as Nest's default one is
|
|
376
|
+
For a body that does not parse (`entity.parse.failed`), one the parser's `verify` refuses (`entity.verify.failed`), or an unsupported content encoding or charset, `HTTP_EXCEPTION_HANDLED` carries a fixed message and the parser `type` in `bodyParserType`, because the parser's message can quote part of the body. While `HttpExceptionFilter` is registered it also writes the response: an `HttpException` keeps its own body, a thrown value that exposes a 4xx status becomes `{ statusCode, message }`, and any other error becomes `500 { statusCode: 500, message: 'Internal server error' }`; the application owns the response only when it registers no such filter. The malformed-JSON case needs the Express adapter and a body parser mounted before `app.init()`, as Nest's default one is. The Fastify adapter is not supported: measured with `@nestjs/platform-fastify` 11.2.9 (Fastify 5.12.8), the same malformed body reaches `HTTP_EXCEPTION_HANDLED` with Fastify's own message and no `bodyParserType`, and the filter's response fails with `res.status(...).json is not a function`. A parser mounted after `app.init()` sits behind the router, so it never runs for a route that matches: that route handles the request without a parsed body (measured: a malformed JSON body to a route answered `201`, and no `HTTP_EXCEPTION_HANDLED` entry was written).
|
|
377
377
|
|
|
378
378
|
> [!IMPORTANT]
|
|
379
379
|
> **Why middleware and not an interceptor.** NestJS runs middleware → guards → interceptors → handler, so an interceptor never sees a request a guard rejected or one that matched no route. Measured against a real backend, 401, 403, 429 and 404 produced no log line at all, which hid brute force and route enumeration. Without the middleware wiring, the interceptor-based behaviour remains, blind spot included.
|
package/dist/server/index.cjs
CHANGED
|
@@ -863,18 +863,15 @@ var I_LIKE = new Map(
|
|
|
863
863
|
var I_LIKE_PAIRS = Array.from(I_LIKE);
|
|
864
864
|
function foldKey(key, keepSeparators = false) {
|
|
865
865
|
if (keepSeparators) {
|
|
866
|
-
|
|
867
|
-
return withLookalikes(
|
|
866
|
+
return matchesPattern(PLAIN, key) ? lowerCase(key) : withLookalikes(
|
|
868
867
|
dropInvisible(readDots(readGlyphs(lowerCase(normalizeText(key, "NFKD"))), "."), ""),
|
|
869
868
|
true
|
|
870
869
|
);
|
|
871
870
|
}
|
|
872
|
-
|
|
873
|
-
return withLookalikes(dropNotName(readGlyphs(lowerCase(normalizeText(key, "NFKD"))), ""), true);
|
|
871
|
+
return matchesPattern(PLAIN, key) ? lowerCase(dropNotAscii(key, "")) : withLookalikes(dropNotName(readGlyphs(lowerCase(normalizeText(key, "NFKD"))), ""), true);
|
|
874
872
|
}
|
|
875
873
|
function foldStrict(key) {
|
|
876
|
-
|
|
877
|
-
return withLookalikes(
|
|
874
|
+
return matchesPattern(PLAIN, key) ? lowerCase(dropNotAscii(key, "")) : withLookalikes(
|
|
878
875
|
dropNotNameStrict(
|
|
879
876
|
standInSymbols(readGlyphs(lowerCase(normalizeText(key, "NFKD"))), SYMBOL_STAND_IN),
|
|
880
877
|
""
|
|
@@ -939,10 +936,11 @@ function matchesFolded(names, folded) {
|
|
|
939
936
|
const { byLength, longest } = groupsOf(names);
|
|
940
937
|
if (longest === 0) return false;
|
|
941
938
|
if (stands > longest) return true;
|
|
942
|
-
|
|
939
|
+
const shortest = letters.length - stands;
|
|
940
|
+
const reach = longest - shortest;
|
|
943
941
|
const lengths = Array.from(
|
|
944
|
-
{ length: wide + stands + 1 },
|
|
945
|
-
(_, extra) => byLength.get(
|
|
942
|
+
{ length: Math.min(wide + stands + 1, reach + 1) },
|
|
943
|
+
(_, extra) => byLength.get(shortest + extra) ?? []
|
|
946
944
|
);
|
|
947
945
|
if (lengths.reduce((count, same) => count + same.length, 0) > MAX_CANDIDATES) return true;
|
|
948
946
|
return lengths.some((same) => same.some((name) => matchesName(letters, [...name])));
|
|
@@ -989,7 +987,8 @@ function matchesKey(names, key) {
|
|
|
989
987
|
// src/server/utils/hide-message-in-stack.util.ts
|
|
990
988
|
function failureTable(message) {
|
|
991
989
|
const table = new Int32Array(message.length);
|
|
992
|
-
|
|
990
|
+
const end = Math.max(1, message.length);
|
|
991
|
+
for (let i = 1, matched = 0; i !== end; i += 1) {
|
|
993
992
|
while (matched > 0 && message[i] !== message[matched]) matched = table[matched - 1];
|
|
994
993
|
if (message[i] === message[matched]) matched += 1;
|
|
995
994
|
table[i] = matched;
|
|
@@ -997,14 +996,14 @@ function failureTable(message) {
|
|
|
997
996
|
return table;
|
|
998
997
|
}
|
|
999
998
|
function occurrences(stack, message) {
|
|
1000
|
-
|
|
1001
|
-
const table = failureTable(
|
|
999
|
+
const searched = message.slice(0, stack.length + 1);
|
|
1000
|
+
const table = failureTable(searched);
|
|
1002
1001
|
const spans = [];
|
|
1003
|
-
for (let i = 0, matched = 0; i
|
|
1004
|
-
while (matched > 0 && stack[i] !==
|
|
1005
|
-
if (stack[i] ===
|
|
1006
|
-
if (matched ===
|
|
1007
|
-
const start = i + 1 -
|
|
1002
|
+
for (let i = 0, matched = 0; i !== stack.length; i += 1) {
|
|
1003
|
+
while (matched > 0 && stack[i] !== searched[matched]) matched = table[matched - 1];
|
|
1004
|
+
if (stack[i] === searched[matched]) matched += 1;
|
|
1005
|
+
if (matched === searched.length) {
|
|
1006
|
+
const start = i + 1 - searched.length;
|
|
1008
1007
|
const last = spans[spans.length - 1];
|
|
1009
1008
|
if (last !== void 0 && start < last[1]) last[1] = i + 1;
|
|
1010
1009
|
else spans.push([start, i + 1]);
|
|
@@ -1254,7 +1253,7 @@ function readOptional(read, node) {
|
|
|
1254
1253
|
}
|
|
1255
1254
|
}
|
|
1256
1255
|
function toSanitizedChild(value, seen, depth2, walk2) {
|
|
1257
|
-
if (
|
|
1256
|
+
if (seen.has(value)) {
|
|
1258
1257
|
return CIRCULAR_SENTINEL;
|
|
1259
1258
|
}
|
|
1260
1259
|
return toSanitizedError(value, seen, depth2, walk2);
|
|
@@ -1319,9 +1318,6 @@ function scrubStack(stack, header, wasLonger = false) {
|
|
|
1319
1318
|
);
|
|
1320
1319
|
return cutText(scrubbed, wasLonger || stack.length > MAX_STACK_SCAN);
|
|
1321
1320
|
}
|
|
1322
|
-
function isObject(value) {
|
|
1323
|
-
return typeof value === "object" && value !== null;
|
|
1324
|
-
}
|
|
1325
1321
|
function createDepthMarker() {
|
|
1326
1322
|
return { _truncated: true, _reason: "cause-depth-exceeded" };
|
|
1327
1323
|
}
|
|
@@ -1432,7 +1428,7 @@ function rulesBelow(rules, key, value, honorToJson) {
|
|
|
1432
1428
|
if (leavesErrorText(rules, key, value, honorToJson)) {
|
|
1433
1429
|
return { ...rules, exemptKeys: ERROR_TEXT_KEYS };
|
|
1434
1430
|
}
|
|
1435
|
-
return
|
|
1431
|
+
return { ...rules, exemptKeys: void 0, headerKept: void 0 };
|
|
1436
1432
|
}
|
|
1437
1433
|
function isCensored(rules, key, value) {
|
|
1438
1434
|
return matchesKey(rules.sensitive, key) && !(typeof value === "string" && rules.exemptKeys?.has(key));
|
|
@@ -2104,8 +2100,7 @@ function hasTokenPart(segment) {
|
|
|
2104
2100
|
}
|
|
2105
2101
|
function withoutExtension(segment) {
|
|
2106
2102
|
const dot = segment.lastIndexOf(".");
|
|
2107
|
-
|
|
2108
|
-
return dotAfterStart && segment.length - dot <= 9 ? segment.slice(0, dot) : segment;
|
|
2103
|
+
return segment.length - dot <= 9 ? segment.slice(0, dot) : segment;
|
|
2109
2104
|
}
|
|
2110
2105
|
function looksLikeToken(value) {
|
|
2111
2106
|
return HEX_SECRET_REGEX.test(value) || HEX_RUN_REGEX.test(value) || JWT_SECRET_REGEX.test(value) || TOKEN_SECRET_REGEX.test(value) && !SLUG_REGEX.test(value) && !UUID_SEGMENT_REGEX.test(value);
|
|
@@ -3181,9 +3176,7 @@ function createTraceContextMixin(logContext, opts) {
|
|
|
3181
3176
|
return function mixin(_mergeObject, _level, _logger) {
|
|
3182
3177
|
const merged = {};
|
|
3183
3178
|
const store = logContext.getStore();
|
|
3184
|
-
|
|
3185
|
-
Object.assign(merged, store);
|
|
3186
|
-
}
|
|
3179
|
+
Object.assign(merged, store);
|
|
3187
3180
|
if (traceApi) {
|
|
3188
3181
|
try {
|
|
3189
3182
|
const span = traceApi.getActiveSpan();
|
|
@@ -3258,8 +3251,7 @@ function rescueToStdout(payload) {
|
|
|
3258
3251
|
function ownQueuedBytes(destination) {
|
|
3259
3252
|
try {
|
|
3260
3253
|
const bytes = destination.queuedBytes?.() ?? 0;
|
|
3261
|
-
|
|
3262
|
-
return positive ? bytes : 0;
|
|
3254
|
+
return Number.isFinite(bytes) ? Math.max(0, bytes) : 0;
|
|
3263
3255
|
} catch {
|
|
3264
3256
|
return 0;
|
|
3265
3257
|
}
|
|
@@ -3331,7 +3323,6 @@ function destinationToStream(destination, health, maxQueueBytes = 0, censorMessa
|
|
|
3331
3323
|
// Keep string chunks as strings (Node's default re-encodes them to Buffers
|
|
3332
3324
|
// before `_write`): the common Pino path emits NDJSON strings, so this skips
|
|
3333
3325
|
// a string→Buffer→string round-trip on the hot logging path.
|
|
3334
|
-
// Stryker disable next-line BooleanLiteral: equivalent for every chunk this stream receives — with `true`, Node encodes the string to a Buffer and `write()` below decodes it back with `toString('utf-8')`. Pino writes UTF-8 NDJSON strings at the default encoding, so the round-trip returns the identical string. It is NOT equivalent in general: a `write(chunk, 'latin1')` would round-trip through UTF-8 and change non-ASCII bytes, which is unreachable here because nothing writes to this stream but Pino. The flag stays because it skips the round-trip on the hot logging path.
|
|
3335
3326
|
decodeStrings: false,
|
|
3336
3327
|
write(chunk, _encoding, settled) {
|
|
3337
3328
|
const bytes = Buffer.byteLength(chunk);
|
|
@@ -3839,16 +3830,16 @@ function withSemconvException(record, format, maxBytes = Number.POSITIVE_INFINIT
|
|
|
3839
3830
|
}
|
|
3840
3831
|
|
|
3841
3832
|
// src/server/utils/serialize-request.util.ts
|
|
3842
|
-
function
|
|
3833
|
+
function isObject(value) {
|
|
3843
3834
|
return typeof value === "object" && value !== null;
|
|
3844
3835
|
}
|
|
3845
3836
|
function isRequest(value) {
|
|
3846
|
-
if (!
|
|
3837
|
+
if (!isObject(value)) return false;
|
|
3847
3838
|
const { rawHeaders, method, socket } = value;
|
|
3848
|
-
return Array.isArray(rawHeaders) || typeof method === "string" &&
|
|
3839
|
+
return Array.isArray(rawHeaders) || typeof method === "string" && isObject(socket);
|
|
3849
3840
|
}
|
|
3850
3841
|
function copyHeaders(headers) {
|
|
3851
|
-
return
|
|
3842
|
+
return isObject(headers) ? { ...headers } : {};
|
|
3852
3843
|
}
|
|
3853
3844
|
function serializeRequestValue(input, secretSegments = []) {
|
|
3854
3845
|
try {
|
|
@@ -4617,7 +4608,9 @@ var DestinationRegistry = class {
|
|
|
4617
4608
|
if (configured === void 0) {
|
|
4618
4609
|
return this.options.level;
|
|
4619
4610
|
}
|
|
4620
|
-
return LOG_LEVEL_PRIORITY.
|
|
4611
|
+
return LOG_LEVEL_PRIORITY.slice(LOG_LEVEL_PRIORITY.indexOf(this.options.level)).includes(
|
|
4612
|
+
configured
|
|
4613
|
+
) ? configured : this.options.level;
|
|
4621
4614
|
}
|
|
4622
4615
|
/**
|
|
4623
4616
|
* Report one destination init failure as a structured
|
|
@@ -5547,8 +5540,8 @@ function isRecord3(value) {
|
|
|
5547
5540
|
}
|
|
5548
5541
|
function exceptionFields(error) {
|
|
5549
5542
|
try {
|
|
5550
|
-
if (!isRecord3(error)
|
|
5551
|
-
const response = error["getResponse"]();
|
|
5543
|
+
if (!isRecord3(error)) return {};
|
|
5544
|
+
const response = error["getResponse"]?.();
|
|
5552
5545
|
if (!isRecord3(response)) return {};
|
|
5553
5546
|
const nested = response["error"];
|
|
5554
5547
|
const carrier = isRecord3(nested) && typeof nested["code"] === "string" ? nested : response;
|
package/dist/server/index.mjs
CHANGED
|
@@ -860,18 +860,15 @@ var I_LIKE = new Map(
|
|
|
860
860
|
var I_LIKE_PAIRS = Array.from(I_LIKE);
|
|
861
861
|
function foldKey(key, keepSeparators = false) {
|
|
862
862
|
if (keepSeparators) {
|
|
863
|
-
|
|
864
|
-
return withLookalikes(
|
|
863
|
+
return matchesPattern(PLAIN, key) ? lowerCase(key) : withLookalikes(
|
|
865
864
|
dropInvisible(readDots(readGlyphs(lowerCase(normalizeText(key, "NFKD"))), "."), ""),
|
|
866
865
|
true
|
|
867
866
|
);
|
|
868
867
|
}
|
|
869
|
-
|
|
870
|
-
return withLookalikes(dropNotName(readGlyphs(lowerCase(normalizeText(key, "NFKD"))), ""), true);
|
|
868
|
+
return matchesPattern(PLAIN, key) ? lowerCase(dropNotAscii(key, "")) : withLookalikes(dropNotName(readGlyphs(lowerCase(normalizeText(key, "NFKD"))), ""), true);
|
|
871
869
|
}
|
|
872
870
|
function foldStrict(key) {
|
|
873
|
-
|
|
874
|
-
return withLookalikes(
|
|
871
|
+
return matchesPattern(PLAIN, key) ? lowerCase(dropNotAscii(key, "")) : withLookalikes(
|
|
875
872
|
dropNotNameStrict(
|
|
876
873
|
standInSymbols(readGlyphs(lowerCase(normalizeText(key, "NFKD"))), SYMBOL_STAND_IN),
|
|
877
874
|
""
|
|
@@ -936,10 +933,11 @@ function matchesFolded(names, folded) {
|
|
|
936
933
|
const { byLength, longest } = groupsOf(names);
|
|
937
934
|
if (longest === 0) return false;
|
|
938
935
|
if (stands > longest) return true;
|
|
939
|
-
|
|
936
|
+
const shortest = letters.length - stands;
|
|
937
|
+
const reach = longest - shortest;
|
|
940
938
|
const lengths = Array.from(
|
|
941
|
-
{ length: wide + stands + 1 },
|
|
942
|
-
(_, extra) => byLength.get(
|
|
939
|
+
{ length: Math.min(wide + stands + 1, reach + 1) },
|
|
940
|
+
(_, extra) => byLength.get(shortest + extra) ?? []
|
|
943
941
|
);
|
|
944
942
|
if (lengths.reduce((count, same) => count + same.length, 0) > MAX_CANDIDATES) return true;
|
|
945
943
|
return lengths.some((same) => same.some((name) => matchesName(letters, [...name])));
|
|
@@ -986,7 +984,8 @@ function matchesKey(names, key) {
|
|
|
986
984
|
// src/server/utils/hide-message-in-stack.util.ts
|
|
987
985
|
function failureTable(message) {
|
|
988
986
|
const table = new Int32Array(message.length);
|
|
989
|
-
|
|
987
|
+
const end = Math.max(1, message.length);
|
|
988
|
+
for (let i = 1, matched = 0; i !== end; i += 1) {
|
|
990
989
|
while (matched > 0 && message[i] !== message[matched]) matched = table[matched - 1];
|
|
991
990
|
if (message[i] === message[matched]) matched += 1;
|
|
992
991
|
table[i] = matched;
|
|
@@ -994,14 +993,14 @@ function failureTable(message) {
|
|
|
994
993
|
return table;
|
|
995
994
|
}
|
|
996
995
|
function occurrences(stack, message) {
|
|
997
|
-
|
|
998
|
-
const table = failureTable(
|
|
996
|
+
const searched = message.slice(0, stack.length + 1);
|
|
997
|
+
const table = failureTable(searched);
|
|
999
998
|
const spans = [];
|
|
1000
|
-
for (let i = 0, matched = 0; i
|
|
1001
|
-
while (matched > 0 && stack[i] !==
|
|
1002
|
-
if (stack[i] ===
|
|
1003
|
-
if (matched ===
|
|
1004
|
-
const start = i + 1 -
|
|
999
|
+
for (let i = 0, matched = 0; i !== stack.length; i += 1) {
|
|
1000
|
+
while (matched > 0 && stack[i] !== searched[matched]) matched = table[matched - 1];
|
|
1001
|
+
if (stack[i] === searched[matched]) matched += 1;
|
|
1002
|
+
if (matched === searched.length) {
|
|
1003
|
+
const start = i + 1 - searched.length;
|
|
1005
1004
|
const last = spans[spans.length - 1];
|
|
1006
1005
|
if (last !== void 0 && start < last[1]) last[1] = i + 1;
|
|
1007
1006
|
else spans.push([start, i + 1]);
|
|
@@ -1251,7 +1250,7 @@ function readOptional(read, node) {
|
|
|
1251
1250
|
}
|
|
1252
1251
|
}
|
|
1253
1252
|
function toSanitizedChild(value, seen, depth2, walk2) {
|
|
1254
|
-
if (
|
|
1253
|
+
if (seen.has(value)) {
|
|
1255
1254
|
return CIRCULAR_SENTINEL;
|
|
1256
1255
|
}
|
|
1257
1256
|
return toSanitizedError(value, seen, depth2, walk2);
|
|
@@ -1316,9 +1315,6 @@ function scrubStack(stack, header, wasLonger = false) {
|
|
|
1316
1315
|
);
|
|
1317
1316
|
return cutText(scrubbed, wasLonger || stack.length > MAX_STACK_SCAN);
|
|
1318
1317
|
}
|
|
1319
|
-
function isObject(value) {
|
|
1320
|
-
return typeof value === "object" && value !== null;
|
|
1321
|
-
}
|
|
1322
1318
|
function createDepthMarker() {
|
|
1323
1319
|
return { _truncated: true, _reason: "cause-depth-exceeded" };
|
|
1324
1320
|
}
|
|
@@ -1429,7 +1425,7 @@ function rulesBelow(rules, key, value, honorToJson) {
|
|
|
1429
1425
|
if (leavesErrorText(rules, key, value, honorToJson)) {
|
|
1430
1426
|
return { ...rules, exemptKeys: ERROR_TEXT_KEYS };
|
|
1431
1427
|
}
|
|
1432
|
-
return
|
|
1428
|
+
return { ...rules, exemptKeys: void 0, headerKept: void 0 };
|
|
1433
1429
|
}
|
|
1434
1430
|
function isCensored(rules, key, value) {
|
|
1435
1431
|
return matchesKey(rules.sensitive, key) && !(typeof value === "string" && rules.exemptKeys?.has(key));
|
|
@@ -2101,8 +2097,7 @@ function hasTokenPart(segment) {
|
|
|
2101
2097
|
}
|
|
2102
2098
|
function withoutExtension(segment) {
|
|
2103
2099
|
const dot = segment.lastIndexOf(".");
|
|
2104
|
-
|
|
2105
|
-
return dotAfterStart && segment.length - dot <= 9 ? segment.slice(0, dot) : segment;
|
|
2100
|
+
return segment.length - dot <= 9 ? segment.slice(0, dot) : segment;
|
|
2106
2101
|
}
|
|
2107
2102
|
function looksLikeToken(value) {
|
|
2108
2103
|
return HEX_SECRET_REGEX.test(value) || HEX_RUN_REGEX.test(value) || JWT_SECRET_REGEX.test(value) || TOKEN_SECRET_REGEX.test(value) && !SLUG_REGEX.test(value) && !UUID_SEGMENT_REGEX.test(value);
|
|
@@ -3178,9 +3173,7 @@ function createTraceContextMixin(logContext, opts) {
|
|
|
3178
3173
|
return function mixin(_mergeObject, _level, _logger) {
|
|
3179
3174
|
const merged = {};
|
|
3180
3175
|
const store = logContext.getStore();
|
|
3181
|
-
|
|
3182
|
-
Object.assign(merged, store);
|
|
3183
|
-
}
|
|
3176
|
+
Object.assign(merged, store);
|
|
3184
3177
|
if (traceApi) {
|
|
3185
3178
|
try {
|
|
3186
3179
|
const span = traceApi.getActiveSpan();
|
|
@@ -3255,8 +3248,7 @@ function rescueToStdout(payload) {
|
|
|
3255
3248
|
function ownQueuedBytes(destination) {
|
|
3256
3249
|
try {
|
|
3257
3250
|
const bytes = destination.queuedBytes?.() ?? 0;
|
|
3258
|
-
|
|
3259
|
-
return positive ? bytes : 0;
|
|
3251
|
+
return Number.isFinite(bytes) ? Math.max(0, bytes) : 0;
|
|
3260
3252
|
} catch {
|
|
3261
3253
|
return 0;
|
|
3262
3254
|
}
|
|
@@ -3328,7 +3320,6 @@ function destinationToStream(destination, health, maxQueueBytes = 0, censorMessa
|
|
|
3328
3320
|
// Keep string chunks as strings (Node's default re-encodes them to Buffers
|
|
3329
3321
|
// before `_write`): the common Pino path emits NDJSON strings, so this skips
|
|
3330
3322
|
// a string→Buffer→string round-trip on the hot logging path.
|
|
3331
|
-
// Stryker disable next-line BooleanLiteral: equivalent for every chunk this stream receives — with `true`, Node encodes the string to a Buffer and `write()` below decodes it back with `toString('utf-8')`. Pino writes UTF-8 NDJSON strings at the default encoding, so the round-trip returns the identical string. It is NOT equivalent in general: a `write(chunk, 'latin1')` would round-trip through UTF-8 and change non-ASCII bytes, which is unreachable here because nothing writes to this stream but Pino. The flag stays because it skips the round-trip on the hot logging path.
|
|
3332
3323
|
decodeStrings: false,
|
|
3333
3324
|
write(chunk, _encoding, settled) {
|
|
3334
3325
|
const bytes = Buffer.byteLength(chunk);
|
|
@@ -3836,16 +3827,16 @@ function withSemconvException(record, format, maxBytes = Number.POSITIVE_INFINIT
|
|
|
3836
3827
|
}
|
|
3837
3828
|
|
|
3838
3829
|
// src/server/utils/serialize-request.util.ts
|
|
3839
|
-
function
|
|
3830
|
+
function isObject(value) {
|
|
3840
3831
|
return typeof value === "object" && value !== null;
|
|
3841
3832
|
}
|
|
3842
3833
|
function isRequest(value) {
|
|
3843
|
-
if (!
|
|
3834
|
+
if (!isObject(value)) return false;
|
|
3844
3835
|
const { rawHeaders, method, socket } = value;
|
|
3845
|
-
return Array.isArray(rawHeaders) || typeof method === "string" &&
|
|
3836
|
+
return Array.isArray(rawHeaders) || typeof method === "string" && isObject(socket);
|
|
3846
3837
|
}
|
|
3847
3838
|
function copyHeaders(headers) {
|
|
3848
|
-
return
|
|
3839
|
+
return isObject(headers) ? { ...headers } : {};
|
|
3849
3840
|
}
|
|
3850
3841
|
function serializeRequestValue(input, secretSegments = []) {
|
|
3851
3842
|
try {
|
|
@@ -4614,7 +4605,9 @@ var DestinationRegistry = class {
|
|
|
4614
4605
|
if (configured === void 0) {
|
|
4615
4606
|
return this.options.level;
|
|
4616
4607
|
}
|
|
4617
|
-
return LOG_LEVEL_PRIORITY.
|
|
4608
|
+
return LOG_LEVEL_PRIORITY.slice(LOG_LEVEL_PRIORITY.indexOf(this.options.level)).includes(
|
|
4609
|
+
configured
|
|
4610
|
+
) ? configured : this.options.level;
|
|
4618
4611
|
}
|
|
4619
4612
|
/**
|
|
4620
4613
|
* Report one destination init failure as a structured
|
|
@@ -5544,8 +5537,8 @@ function isRecord3(value) {
|
|
|
5544
5537
|
}
|
|
5545
5538
|
function exceptionFields(error) {
|
|
5546
5539
|
try {
|
|
5547
|
-
if (!isRecord3(error)
|
|
5548
|
-
const response = error["getResponse"]();
|
|
5540
|
+
if (!isRecord3(error)) return {};
|
|
5541
|
+
const response = error["getResponse"]?.();
|
|
5549
5542
|
if (!isRecord3(response)) return {};
|
|
5550
5543
|
const nested = response["error"];
|
|
5551
5544
|
const carrier = isRecord3(nested) && typeof nested["code"] === "string" ? nested : response;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bymax-one/nest-logger",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.31",
|
|
4
4
|
"description": "Structured JSON logging for NestJS based on Pino 10, with optional OpenTelemetry correlation.",
|
|
5
5
|
"author": "Bymax One <support@bymax.one>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
"check:suppressions": "node scripts/check-suppressions-baseline.mjs",
|
|
82
82
|
"clean": "rm -rf dist coverage",
|
|
83
83
|
"check:socket-gate": "node scripts/check-socket-gate.mjs",
|
|
84
|
-
"lint": "eslint src scripts test bench '*.config.ts' '*.config.mjs' '*.config.cjs' && pnpm check:socket-gate && pnpm check:spec-headers && node --test scripts/check-spec-headers.test.mjs && node --test scripts/check-suppressions-baseline.test.mjs && pnpm check:property-path && node --test scripts/check-have-property-path.test.mjs && node --test scripts/generate-glyph-letters.test.mjs",
|
|
84
|
+
"lint": "eslint src scripts test bench '*.config.ts' '*.config.mjs' '*.config.cjs' && pnpm check:socket-gate && pnpm check:spec-headers && node --test scripts/check-spec-headers.test.mjs && node --test scripts/check-suppressions-baseline.test.mjs && pnpm check:property-path && node --test scripts/check-have-property-path.test.mjs && node --test scripts/check-dist-fresh.test.mjs && node --test scripts/generate-glyph-letters.test.mjs",
|
|
85
85
|
"lint:fix": "eslint src scripts test bench '*.config.ts' '*.config.mjs' '*.config.cjs' --fix",
|
|
86
86
|
"mutation": "stryker run",
|
|
87
87
|
"mutation:full": "node -e \"require('node:fs').rmSync('reports/stryker-incremental.json',{force:true,recursive:true})\" && stryker run",
|
|
@@ -89,7 +89,7 @@
|
|
|
89
89
|
"prepare": "husky",
|
|
90
90
|
"prepublishOnly": "pnpm clean && pnpm typecheck && pnpm lint && pnpm check:mutants && pnpm check:docs && pnpm test:cov:all && pnpm build && pnpm check:published",
|
|
91
91
|
"release": "npm publish --provenance --access public",
|
|
92
|
-
"size": "node scripts/check-size.mjs",
|
|
92
|
+
"size": "node scripts/check-dist-fresh.mjs && node scripts/check-size.mjs",
|
|
93
93
|
"test": "jest",
|
|
94
94
|
"test:all": "pnpm test && pnpm test:e2e",
|
|
95
95
|
"test:cov": "jest --coverage",
|
|
@@ -158,6 +158,7 @@
|
|
|
158
158
|
"eslint-plugin-import": "^2.32.0",
|
|
159
159
|
"eslint-plugin-prettier": "^5.5.5",
|
|
160
160
|
"eslint-plugin-security": "^4.0.0",
|
|
161
|
+
"express": "^5.2.1",
|
|
161
162
|
"globals": "^17.6.0",
|
|
162
163
|
"husky": "^9.1.7",
|
|
163
164
|
"jest": "^30.4.2",
|