@bymax-one/nest-logger 1.4.10 → 1.4.11
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 +60 -1
- package/README.md +42 -23
- package/dist/server/index.cjs +311 -164
- package/dist/server/index.d.cts +23 -1
- package/dist/server/index.d.ts +23 -1
- package/dist/server/index.mjs +311 -164
- package/package.json +1 -1
package/dist/server/index.cjs
CHANGED
|
@@ -83,6 +83,8 @@ function applyDefaults(options) {
|
|
|
83
83
|
}),
|
|
84
84
|
otel: Object.freeze(otel),
|
|
85
85
|
maxEntrySizeBytes: options.maxEntrySizeBytes ?? DEFAULT_MAX_ENTRY_SIZE_BYTES,
|
|
86
|
+
errorOwnFields: options.errorOwnFields ?? "all",
|
|
87
|
+
errorOwnFieldNames: Object.freeze([...options.errorOwnFieldNames ?? []]),
|
|
86
88
|
serializers: Object.freeze({ ...options.serializers ?? {} }),
|
|
87
89
|
timestamp: options.timestamp ?? (() => (/* @__PURE__ */ new Date()).toISOString())
|
|
88
90
|
};
|
|
@@ -227,6 +229,20 @@ function validateCustomization(options) {
|
|
|
227
229
|
}
|
|
228
230
|
}
|
|
229
231
|
}
|
|
232
|
+
function validateErrorFields(options) {
|
|
233
|
+
const mode = options.errorOwnFields;
|
|
234
|
+
if (mode !== void 0 && mode !== "all" && mode !== "safe") {
|
|
235
|
+
reject("errorOwnFields", "must be 'all' or 'safe'", mode);
|
|
236
|
+
}
|
|
237
|
+
const names = options.errorOwnFieldNames;
|
|
238
|
+
if (names === void 0) return;
|
|
239
|
+
if (!Array.isArray(names)) reject("errorOwnFieldNames", "must be an array of strings", names);
|
|
240
|
+
names.forEach((entry, index) => {
|
|
241
|
+
if (!isNonEmptyString(entry)) {
|
|
242
|
+
reject(`errorOwnFieldNames[${String(index)}]`, "must be a non-empty string", entry);
|
|
243
|
+
}
|
|
244
|
+
});
|
|
245
|
+
}
|
|
230
246
|
var UNREADABLE = /* @__PURE__ */ Symbol("unreadable");
|
|
231
247
|
function readMember(destination, key) {
|
|
232
248
|
try {
|
|
@@ -298,6 +314,7 @@ function validateOptions(options) {
|
|
|
298
314
|
validateCore(options);
|
|
299
315
|
validateClosedSets(options);
|
|
300
316
|
validateCustomization(options);
|
|
317
|
+
validateErrorFields(options);
|
|
301
318
|
validateDestinations(options);
|
|
302
319
|
validateHttp(options);
|
|
303
320
|
validateOtel(options);
|
|
@@ -353,6 +370,20 @@ var PROTOTYPE_POLLUTING_KEYS = /* @__PURE__ */ new Set([
|
|
|
353
370
|
"prototype"
|
|
354
371
|
]);
|
|
355
372
|
|
|
373
|
+
// src/server/utils/bounded-text.util.ts
|
|
374
|
+
var MAX_TEXT_LENGTH = 16384;
|
|
375
|
+
var TEXT_TRUNCATED = "\u2026[truncated]";
|
|
376
|
+
function cutIfText(value) {
|
|
377
|
+
return typeof value === "string" ? cutText(value) : value;
|
|
378
|
+
}
|
|
379
|
+
function cutText(text, alreadyCut = false) {
|
|
380
|
+
if (!alreadyCut && text.length <= MAX_TEXT_LENGTH) return text;
|
|
381
|
+
const head = text.slice(0, MAX_TEXT_LENGTH);
|
|
382
|
+
const last = head.charCodeAt(head.length - 1);
|
|
383
|
+
const whole = last >= 55296 && last <= 56319 ? head.slice(0, -1) : head;
|
|
384
|
+
return whole + TEXT_TRUNCATED;
|
|
385
|
+
}
|
|
386
|
+
|
|
356
387
|
// src/server/utils/escape-log-text.util.ts
|
|
357
388
|
var LINE_TERMINATORS = /* @__PURE__ */ new Set(["\r", "\n", "\x85", "\u2028", "\u2029"]);
|
|
358
389
|
var UNSAFE_IN_SINGLE_LINE = /[\u0000-\u0008\u000A-\u001F\u007F-\u009F\u2028\u2029]/g;
|
|
@@ -366,14 +397,35 @@ function toSingleLineMessage(text) {
|
|
|
366
397
|
(char) => LINE_TERMINATORS.has(char) ? "\\n" : toEscapeSequence(char)
|
|
367
398
|
);
|
|
368
399
|
}
|
|
400
|
+
function toBoundedMessage(text) {
|
|
401
|
+
return cutText(toSingleLineMessage(text));
|
|
402
|
+
}
|
|
369
403
|
function escapeControlCharacters(text) {
|
|
370
404
|
return text.replace(UNSAFE_IN_MULTILINE, toEscapeSequence);
|
|
371
405
|
}
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
406
|
+
function isError(value) {
|
|
407
|
+
try {
|
|
408
|
+
return util.types.isNativeError(value) || value instanceof Error;
|
|
409
|
+
} catch {
|
|
410
|
+
return false;
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
var DEFAULT_SAFE_ERROR_FIELDS = [
|
|
414
|
+
"code",
|
|
415
|
+
"errno",
|
|
416
|
+
"syscall",
|
|
417
|
+
"signal",
|
|
418
|
+
"status",
|
|
419
|
+
"statusCode",
|
|
420
|
+
"address",
|
|
421
|
+
"port",
|
|
422
|
+
"hostname",
|
|
423
|
+
"constraint",
|
|
424
|
+
"table",
|
|
425
|
+
"column",
|
|
426
|
+
"schema",
|
|
427
|
+
"routine"
|
|
428
|
+
];
|
|
377
429
|
var DERIVED_ERROR_FIELDS = /* @__PURE__ */ new Set([
|
|
378
430
|
"name",
|
|
379
431
|
"message",
|
|
@@ -381,15 +433,47 @@ var DERIVED_ERROR_FIELDS = /* @__PURE__ */ new Set([
|
|
|
381
433
|
"cause",
|
|
382
434
|
"errors"
|
|
383
435
|
]);
|
|
436
|
+
var ALL_OWN_FIELDS = { safe: false, names: /* @__PURE__ */ new Set() };
|
|
437
|
+
function createOwnFieldPolicy(mode, extraNames) {
|
|
438
|
+
if (mode === "all") return ALL_OWN_FIELDS;
|
|
439
|
+
return { safe: true, names: /* @__PURE__ */ new Set([...DEFAULT_SAFE_ERROR_FIELDS, ...extraNames]) };
|
|
440
|
+
}
|
|
441
|
+
function allowsOwnField(policy, key) {
|
|
442
|
+
return !policy.safe || DERIVED_ERROR_FIELDS.has(key) || key === "_errorFieldsIncomplete" || policy.names.has(key);
|
|
443
|
+
}
|
|
444
|
+
var TYPED_ARRAY_BYTE_LENGTH = Reflect.getOwnPropertyDescriptor(
|
|
445
|
+
Object.getPrototypeOf(Uint8Array.prototype),
|
|
446
|
+
"byteLength"
|
|
447
|
+
)?.get;
|
|
448
|
+
var DATA_VIEW_BYTE_LENGTH = Reflect.getOwnPropertyDescriptor(DataView.prototype, "byteLength")?.get;
|
|
449
|
+
function binaryMarker(view) {
|
|
450
|
+
const size = util.types.isDataView(view) ? DATA_VIEW_BYTE_LENGTH.call(view) : TYPED_ARRAY_BYTE_LENGTH.call(view);
|
|
451
|
+
return `[Binary ${size} bytes]`;
|
|
452
|
+
}
|
|
453
|
+
function withBinaryAsSize(value) {
|
|
454
|
+
if (ArrayBuffer.isView(value)) return binaryMarker(value);
|
|
455
|
+
if (!Array.isArray(value) || !value.some((member) => ArrayBuffer.isView(member))) return value;
|
|
456
|
+
return value.map(
|
|
457
|
+
(member) => ArrayBuffer.isView(member) ? binaryMarker(member) : member
|
|
458
|
+
);
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
// src/server/utils/sanitize-error.util.ts
|
|
462
|
+
var DEFAULT_MAX_CAUSE_DEPTH = 3;
|
|
463
|
+
var MAX_AGGREGATE_ERRORS = 10;
|
|
464
|
+
var CIRCULAR_SENTINEL = "[Circular]";
|
|
384
465
|
function sanitizeError(err, options) {
|
|
385
|
-
const maxCauseDepth = DEFAULT_MAX_CAUSE_DEPTH;
|
|
386
|
-
return toSanitizedError(err, /* @__PURE__ */ new WeakSet(), 0,
|
|
466
|
+
const maxCauseDepth = options?.maxCauseDepth ?? DEFAULT_MAX_CAUSE_DEPTH;
|
|
467
|
+
return toSanitizedError(err, /* @__PURE__ */ new WeakSet(), 0, {
|
|
468
|
+
maxDepth: maxCauseDepth,
|
|
469
|
+
ownFields: options?.ownFields ?? ALL_OWN_FIELDS
|
|
470
|
+
});
|
|
387
471
|
}
|
|
388
472
|
function isErrorLike(value) {
|
|
389
473
|
try {
|
|
390
474
|
return readsAsError(value);
|
|
391
475
|
} catch {
|
|
392
|
-
return
|
|
476
|
+
return isError(value);
|
|
393
477
|
}
|
|
394
478
|
}
|
|
395
479
|
function readsAsError(value) {
|
|
@@ -399,40 +483,32 @@ function readsAsError(value) {
|
|
|
399
483
|
const candidate = value;
|
|
400
484
|
return typeof candidate.name === "string" && typeof candidate.message === "string";
|
|
401
485
|
}
|
|
402
|
-
function
|
|
403
|
-
try {
|
|
404
|
-
return value instanceof Error;
|
|
405
|
-
} catch {
|
|
406
|
-
return false;
|
|
407
|
-
}
|
|
408
|
-
}
|
|
409
|
-
function toSanitizedError(value, seen, depth2, maxDepth) {
|
|
486
|
+
function toSanitizedError(value, seen, depth2, walk2) {
|
|
410
487
|
try {
|
|
411
488
|
if (!readsAsError(value)) {
|
|
412
|
-
return { name: "UnknownError", message: String(value) };
|
|
489
|
+
return { name: "UnknownError", message: cutText(String(value)) };
|
|
413
490
|
}
|
|
414
491
|
seen.add(value);
|
|
415
|
-
const result = { name: value.name, message: value.message };
|
|
492
|
+
const result = { name: cutText(value.name), message: cutText(value.message) };
|
|
416
493
|
const stack = readOptional(() => value.stack, result);
|
|
417
494
|
if (stack !== void 0) {
|
|
418
495
|
result.stack = scrubStack(stack);
|
|
419
496
|
}
|
|
420
|
-
const isAtDepthLimit = depth2 >= maxDepth;
|
|
497
|
+
const isAtDepthLimit = depth2 >= walk2.maxDepth;
|
|
421
498
|
const cause = readOptional(() => value.cause, result);
|
|
422
499
|
if (cause !== void 0) {
|
|
423
|
-
result.cause = isAtDepthLimit ? createDepthMarker() : toSanitizedChild(cause, seen, depth2 + 1,
|
|
500
|
+
result.cause = isAtDepthLimit ? createDepthMarker() : toSanitizedChild(cause, seen, depth2 + 1, walk2);
|
|
424
501
|
}
|
|
425
502
|
const aggregated = readAggregatedErrors(value);
|
|
426
503
|
if (aggregated !== void 0) {
|
|
427
504
|
const capped = aggregated.slice(0, MAX_AGGREGATE_ERRORS);
|
|
428
505
|
result.errors = capped.map(
|
|
429
|
-
(inner) => isAtDepthLimit ? createDepthMarker() : toSanitizedChild(inner, seen, depth2 + 1,
|
|
506
|
+
(inner) => isAtDepthLimit ? createDepthMarker() : toSanitizedChild(inner, seen, depth2 + 1, walk2)
|
|
430
507
|
);
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
}
|
|
508
|
+
const left = carriedOmitted(aggregated) || aggregated.length - MAX_AGGREGATE_ERRORS;
|
|
509
|
+
if (left > 0) result.errors.push(createWidthMarker(left));
|
|
434
510
|
}
|
|
435
|
-
assignOwnErrorFields(result, value);
|
|
511
|
+
assignOwnErrorFields(result, value, walk2.ownFields);
|
|
436
512
|
return result;
|
|
437
513
|
} catch {
|
|
438
514
|
return { name: "SanitizeFailed", message: "Failed to sanitize the thrown value" };
|
|
@@ -446,21 +522,27 @@ function isDatabaseError(source) {
|
|
|
446
522
|
const code = Object.getOwnPropertyDescriptor(source, "code")?.value;
|
|
447
523
|
return typeof code === "string" && SQLSTATE.test(code);
|
|
448
524
|
}
|
|
449
|
-
function ownFieldForLog(source, key, value) {
|
|
525
|
+
function ownFieldForLog(source, key, value, policy = ALL_OWN_FIELDS) {
|
|
526
|
+
if (!allowsOwnField(policy, key)) return OMIT_OWN_FIELD;
|
|
450
527
|
if (ARGUMENT_FIELDS.has(key.toLowerCase())) return OMIT_OWN_FIELD;
|
|
451
528
|
if (DATABASE_VALUE_FIELDS.has(key) && isDatabaseError(source)) return OMIT_OWN_FIELD;
|
|
452
|
-
if (key !== "command" || typeof value !== "object" || value === null)
|
|
529
|
+
if (key !== "command" || typeof value !== "object" || value === null) {
|
|
530
|
+
return withBinaryAsSize(value);
|
|
531
|
+
}
|
|
453
532
|
const name = Object.getOwnPropertyDescriptor(value, "name")?.value;
|
|
454
533
|
return typeof name === "string" ? { name } : OMIT_OWN_FIELD;
|
|
455
534
|
}
|
|
456
|
-
function
|
|
535
|
+
function defineErrorField(target, key, value) {
|
|
536
|
+
Object.defineProperty(target, key, { value, enumerable: true });
|
|
537
|
+
}
|
|
538
|
+
function assignOwnErrorFields(target, source, policy = ALL_OWN_FIELDS) {
|
|
457
539
|
try {
|
|
458
540
|
const own = Array.isArray(source) ? {} : source;
|
|
459
541
|
for (const [key, field] of Object.entries(own)) {
|
|
460
|
-
const value = ownFieldForLog(own, key, field);
|
|
542
|
+
const value = ownFieldForLog(own, key, field, policy);
|
|
461
543
|
if (value === OMIT_OWN_FIELD) continue;
|
|
462
544
|
if (!Object.hasOwn(target, key) && !DERIVED_ERROR_FIELDS.has(key)) {
|
|
463
|
-
|
|
545
|
+
defineErrorField(target, key, value);
|
|
464
546
|
}
|
|
465
547
|
}
|
|
466
548
|
} catch {
|
|
@@ -478,34 +560,32 @@ function readOptional(read, node) {
|
|
|
478
560
|
return void 0;
|
|
479
561
|
}
|
|
480
562
|
}
|
|
481
|
-
function toSanitizedChild(value, seen, depth2,
|
|
563
|
+
function toSanitizedChild(value, seen, depth2, walk2) {
|
|
482
564
|
if (isObject(value) && seen.has(value)) {
|
|
483
565
|
return CIRCULAR_SENTINEL;
|
|
484
566
|
}
|
|
485
|
-
return toSanitizedError(value, seen, depth2,
|
|
567
|
+
return toSanitizedError(value, seen, depth2, walk2);
|
|
568
|
+
}
|
|
569
|
+
function carriedOmitted(list) {
|
|
570
|
+
if (list.length > MAX_AGGREGATE_ERRORS + 1) return 0;
|
|
571
|
+
try {
|
|
572
|
+
const cut = list.at(MAX_AGGREGATE_ERRORS);
|
|
573
|
+
const omitted = cut?._truncated === true ? cut._omitted : void 0;
|
|
574
|
+
return Number.isInteger(omitted) ? Math.max(omitted, 0) : 0;
|
|
575
|
+
} catch {
|
|
576
|
+
return 0;
|
|
577
|
+
}
|
|
486
578
|
}
|
|
487
579
|
function readAggregatedErrors(value) {
|
|
488
580
|
const candidate = value.errors;
|
|
489
581
|
return Array.isArray(candidate) ? candidate : void 0;
|
|
490
582
|
}
|
|
491
|
-
var
|
|
492
|
-
var STACK_TRUNCATED = "\u2026[truncated]";
|
|
493
|
-
var MAX_STACK_SCAN = 8 * MAX_STACK_LENGTH;
|
|
583
|
+
var MAX_STACK_SCAN = 8 * MAX_TEXT_LENGTH;
|
|
494
584
|
function scrubStack(stack) {
|
|
495
585
|
const scrubbed = escapeControlCharacters(
|
|
496
586
|
stack.slice(0, MAX_STACK_SCAN).split("\n").filter((line) => !line.includes("node_modules")).join("\n")
|
|
497
587
|
);
|
|
498
|
-
return
|
|
499
|
-
}
|
|
500
|
-
function cutAtLimit(text, alreadyCut) {
|
|
501
|
-
if (!alreadyCut && text.length <= MAX_STACK_LENGTH) return text;
|
|
502
|
-
const head = text.slice(0, MAX_STACK_LENGTH);
|
|
503
|
-
const last = head.charCodeAt(head.length - 1);
|
|
504
|
-
const whole = last >= 55296 && last <= 56319 ? head.slice(0, -1) : head;
|
|
505
|
-
return whole + STACK_TRUNCATED;
|
|
506
|
-
}
|
|
507
|
-
function cutStack(stack) {
|
|
508
|
-
return cutAtLimit(stack, false);
|
|
588
|
+
return cutText(scrubbed, stack.length > MAX_STACK_SCAN);
|
|
509
589
|
}
|
|
510
590
|
function isObject(value) {
|
|
511
591
|
return typeof value === "object" && value !== null;
|
|
@@ -540,14 +620,14 @@ function withoutOwnedKeys(metadata) {
|
|
|
540
620
|
}
|
|
541
621
|
function safeErrorMessage(error) {
|
|
542
622
|
try {
|
|
543
|
-
return
|
|
623
|
+
return toBoundedMessage(String(error.message));
|
|
544
624
|
} catch {
|
|
545
625
|
return "Unreadable error message";
|
|
546
626
|
}
|
|
547
627
|
}
|
|
548
628
|
function safeLogMessage(message) {
|
|
549
629
|
try {
|
|
550
|
-
return
|
|
630
|
+
return toBoundedMessage(typeof message === "string" ? message : String(message));
|
|
551
631
|
} catch {
|
|
552
632
|
return "Unreadable log message";
|
|
553
633
|
}
|
|
@@ -621,7 +701,7 @@ exports.PinoLoggerService = class PinoLoggerService {
|
|
|
621
701
|
const context = typeof optionalParams[1] === "string" ? optionalParams[1] : this.context;
|
|
622
702
|
const payload = {};
|
|
623
703
|
assignIfDefined(payload, "context", context);
|
|
624
|
-
assignIfDefined(payload, "stack", stack === void 0 ? stack :
|
|
704
|
+
assignIfDefined(payload, "stack", stack === void 0 ? stack : cutText(stack));
|
|
625
705
|
assignIfDefined(payload, "err", findErrorParam(optionalParams));
|
|
626
706
|
this.pino.error(payload, safeLogMessage(message));
|
|
627
707
|
}
|
|
@@ -767,7 +847,7 @@ exports.PinoLoggerService = class PinoLoggerService {
|
|
|
767
847
|
const payload = { ...withoutOwnedKeys(metadata), logKey };
|
|
768
848
|
assignIfDefined(payload, "userId", userId);
|
|
769
849
|
assignIfDefined(payload, "context", this.context);
|
|
770
|
-
const line =
|
|
850
|
+
const line = toBoundedMessage(message);
|
|
771
851
|
if (level === "info") {
|
|
772
852
|
this.pino.info(payload, line);
|
|
773
853
|
} else {
|
|
@@ -1000,7 +1080,7 @@ function readRecordedError(req) {
|
|
|
1000
1080
|
return Reflect.get(req, RECORDED_ERROR);
|
|
1001
1081
|
}
|
|
1002
1082
|
function toError(thrown) {
|
|
1003
|
-
return thrown
|
|
1083
|
+
return isError(thrown) ? thrown : new Error(String(thrown));
|
|
1004
1084
|
}
|
|
1005
1085
|
function readUserId(req) {
|
|
1006
1086
|
return req.user?.sub ?? req.user?.id;
|
|
@@ -1161,7 +1241,7 @@ exports.HttpLoggingInterceptor = class HttpLoggingInterceptor {
|
|
|
1161
1241
|
RESERVED_LOG_KEYS.HTTP_REQUEST_CLIENT_ERROR,
|
|
1162
1242
|
`${method} ${url} \u2192 ${statusCode}`,
|
|
1163
1243
|
userId,
|
|
1164
|
-
{ method, url, statusCode, duration, errorMessage: err.message }
|
|
1244
|
+
{ method, url, statusCode, duration, errorMessage: cutIfText(err.message) }
|
|
1165
1245
|
);
|
|
1166
1246
|
}
|
|
1167
1247
|
return;
|
|
@@ -1291,10 +1371,10 @@ function reportDestinationFailure(logKey, name, cause, msg) {
|
|
|
1291
1371
|
var UNREADABLE_CAUSE = { type: "UnknownError", message: "unreadable value" };
|
|
1292
1372
|
function describeCause(cause) {
|
|
1293
1373
|
try {
|
|
1294
|
-
return cause
|
|
1295
|
-
type:
|
|
1296
|
-
message:
|
|
1297
|
-
} : { type: "UnknownError", message:
|
|
1374
|
+
return isError(cause) ? {
|
|
1375
|
+
type: toBoundedMessage(String(cause.name)),
|
|
1376
|
+
message: toBoundedMessage(String(cause.message))
|
|
1377
|
+
} : { type: "UnknownError", message: toBoundedMessage(String(cause)) };
|
|
1298
1378
|
} catch {
|
|
1299
1379
|
return UNREADABLE_CAUSE;
|
|
1300
1380
|
}
|
|
@@ -1484,29 +1564,114 @@ function destinationToStream(destination, health) {
|
|
|
1484
1564
|
});
|
|
1485
1565
|
}
|
|
1486
1566
|
|
|
1567
|
+
// src/server/utils/redact-error-parts.util.ts
|
|
1568
|
+
function defineOwn(target, key, value) {
|
|
1569
|
+
Reflect.defineProperty(target, key, { value, enumerable: true });
|
|
1570
|
+
}
|
|
1571
|
+
var linkDepths = /* @__PURE__ */ new WeakMap();
|
|
1572
|
+
var ERROR_TEXT_FIELDS = /* @__PURE__ */ new Set(["name", "message", "stack"]);
|
|
1573
|
+
var INCOMPLETE_KEY = "_errorFieldsIncomplete";
|
|
1574
|
+
var widthMarkers = /* @__PURE__ */ new WeakSet();
|
|
1575
|
+
function capErrors(errors, host) {
|
|
1576
|
+
if (!Array.isArray(errors) || errors.length <= MAX_AGGREGATE_ERRORS) return errors;
|
|
1577
|
+
if (host.hasToJson(errors)) return errors;
|
|
1578
|
+
const kept = [];
|
|
1579
|
+
for (let index = 0; index < MAX_AGGREGATE_ERRORS; index++) kept.push(Reflect.get(errors, index));
|
|
1580
|
+
const marker = createWidthMarker(errors.length - MAX_AGGREGATE_ERRORS);
|
|
1581
|
+
widthMarkers.add(marker);
|
|
1582
|
+
kept.push(marker);
|
|
1583
|
+
return kept;
|
|
1584
|
+
}
|
|
1585
|
+
function linkTargets(value) {
|
|
1586
|
+
const targets = [];
|
|
1587
|
+
const take = (link) => {
|
|
1588
|
+
if (typeof link === "object" && link !== null) targets.push(link);
|
|
1589
|
+
};
|
|
1590
|
+
if (!Array.isArray(value)) take(value);
|
|
1591
|
+
else for (let index = 0; index < value.length; index++) take(Reflect.get(value, index));
|
|
1592
|
+
return targets;
|
|
1593
|
+
}
|
|
1594
|
+
function walkChainPart(value, level, host, depth2) {
|
|
1595
|
+
const targets = linkTargets(value);
|
|
1596
|
+
if (targets.length > 0 && level + 1 > DEFAULT_MAX_CAUSE_DEPTH) {
|
|
1597
|
+
if (Array.isArray(value) && host.nameKey === "name") {
|
|
1598
|
+
return Array.from({ length: value.length }, (_member, index) => {
|
|
1599
|
+
const member = Reflect.get(value, index);
|
|
1600
|
+
return typeof member === "object" && member !== null && widthMarkers.has(member) ? member : createDepthMarker();
|
|
1601
|
+
});
|
|
1602
|
+
}
|
|
1603
|
+
return createDepthMarker();
|
|
1604
|
+
}
|
|
1605
|
+
const before = new Map(targets.map((target) => [target, linkDepths.get(target)]));
|
|
1606
|
+
for (const target of targets) linkDepths.set(target, level + 1);
|
|
1607
|
+
try {
|
|
1608
|
+
return host.walk(value, depth2 + 1);
|
|
1609
|
+
} finally {
|
|
1610
|
+
before.forEach((earlier, target) => {
|
|
1611
|
+
if (earlier === void 0) linkDepths.delete(target);
|
|
1612
|
+
else linkDepths.set(target, earlier);
|
|
1613
|
+
});
|
|
1614
|
+
}
|
|
1615
|
+
}
|
|
1616
|
+
function cutOrWalk(value, level, host, depth2) {
|
|
1617
|
+
return typeof value === "string" ? cutText(value) : walkChainPart(value, level, host, depth2);
|
|
1618
|
+
}
|
|
1619
|
+
function addErrorParts(copy, error, ownKeys, host, depth2) {
|
|
1620
|
+
const taken = new Set(ownKeys);
|
|
1621
|
+
const level = linkDepths.get(error) ?? 0;
|
|
1622
|
+
let incomplete = false;
|
|
1623
|
+
const add = (key, covers, read, write = (value) => walkChainPart(value, level, host, depth2)) => {
|
|
1624
|
+
if (taken.has(key)) return;
|
|
1625
|
+
try {
|
|
1626
|
+
const written = write(read());
|
|
1627
|
+
if (written === void 0) return;
|
|
1628
|
+
const covered = covers.some((name) => host.sensitive.has(name));
|
|
1629
|
+
defineOwn(copy, key, covered ? host.censor : written);
|
|
1630
|
+
} catch {
|
|
1631
|
+
incomplete = true;
|
|
1632
|
+
}
|
|
1633
|
+
};
|
|
1634
|
+
add(
|
|
1635
|
+
host.nameKey,
|
|
1636
|
+
[host.nameKey, "name"],
|
|
1637
|
+
() => error.name,
|
|
1638
|
+
(name) => cutOrWalk(name, level, host, depth2)
|
|
1639
|
+
);
|
|
1640
|
+
add(
|
|
1641
|
+
"message",
|
|
1642
|
+
["message"],
|
|
1643
|
+
() => error.message,
|
|
1644
|
+
(message) => cutOrWalk(message, level, host, depth2)
|
|
1645
|
+
);
|
|
1646
|
+
add(
|
|
1647
|
+
"stack",
|
|
1648
|
+
["stack", "name", "message"],
|
|
1649
|
+
() => error.stack,
|
|
1650
|
+
(stack) => typeof stack === "string" ? scrubStack(stack) : void 0
|
|
1651
|
+
);
|
|
1652
|
+
add("cause", ["cause"], () => error.cause);
|
|
1653
|
+
add("errors", ["errors"], () => capErrors(error.errors, host));
|
|
1654
|
+
if (incomplete && !taken.has(INCOMPLETE_KEY)) defineOwn(copy, INCOMPLETE_KEY, true);
|
|
1655
|
+
}
|
|
1656
|
+
|
|
1487
1657
|
// src/server/utils/redact-by-name.util.ts
|
|
1488
1658
|
var REDACT_MAX_TRAVERSAL_DEPTH = 100;
|
|
1489
1659
|
var REDACT_DEPTH_EXCEEDED = "[REDACTION_DEPTH_EXCEEDED]";
|
|
1490
1660
|
var REDACT_MAX_VISITS = 2e5;
|
|
1491
1661
|
var REDACT_BUDGET_EXCEEDED = "[REDACTION_BUDGET_EXCEEDED]";
|
|
1492
1662
|
var REDACT_CIRCULAR = "[Circular]";
|
|
1493
|
-
function resolveToJson(value) {
|
|
1494
|
-
let
|
|
1495
|
-
let
|
|
1496
|
-
let current = value;
|
|
1663
|
+
function resolveToJson(value, viaGet = false) {
|
|
1664
|
+
let candidate = viaGet ? Reflect.get(value, "toJSON") : void 0;
|
|
1665
|
+
let current = viaGet ? null : value;
|
|
1497
1666
|
while (current !== null) {
|
|
1498
1667
|
const descriptor = Object.getOwnPropertyDescriptor(current, "toJSON");
|
|
1499
1668
|
if (descriptor !== void 0) {
|
|
1500
|
-
|
|
1501
|
-
candidate = getter === void 0 ? descriptor.value : getter.call(value);
|
|
1669
|
+
candidate = descriptor.get === void 0 ? descriptor.value : descriptor.get.call(value);
|
|
1502
1670
|
break;
|
|
1503
1671
|
}
|
|
1504
1672
|
current = Object.getPrototypeOf(current);
|
|
1505
1673
|
}
|
|
1506
|
-
return {
|
|
1507
|
-
method: typeof candidate === "function" ? candidate : void 0,
|
|
1508
|
-
fromAccessor: getter !== void 0
|
|
1509
|
-
};
|
|
1674
|
+
return { method: typeof candidate === "function" ? candidate : void 0 };
|
|
1510
1675
|
}
|
|
1511
1676
|
function cloneError(error) {
|
|
1512
1677
|
const descriptors = Object.getOwnPropertyDescriptors(error);
|
|
@@ -1520,10 +1685,6 @@ function cloneError(error) {
|
|
|
1520
1685
|
}
|
|
1521
1686
|
return clone;
|
|
1522
1687
|
}
|
|
1523
|
-
var BUFFER_TO_JSON = Buffer.prototype.toJSON;
|
|
1524
|
-
function defineOwn(target, key, value) {
|
|
1525
|
-
Reflect.defineProperty(target, key, { value, enumerable: true });
|
|
1526
|
-
}
|
|
1527
1688
|
function walkArray(value, rules, depth2, ancestors, inSerialized) {
|
|
1528
1689
|
const length = value.length;
|
|
1529
1690
|
const copy = [];
|
|
@@ -1536,12 +1697,12 @@ function walkArray(value, rules, depth2, ancestors, inSerialized) {
|
|
|
1536
1697
|
}
|
|
1537
1698
|
return copy;
|
|
1538
1699
|
}
|
|
1539
|
-
function walk(value, rules, depth2, ancestors, honorToJson
|
|
1700
|
+
function walk(value, rules, depth2, ancestors, honorToJson, inSerialized = false) {
|
|
1540
1701
|
if (value === null) {
|
|
1541
1702
|
return value;
|
|
1542
1703
|
}
|
|
1543
1704
|
if (typeof value !== "object" && typeof value !== "function") {
|
|
1544
|
-
return value;
|
|
1705
|
+
return typeof value === "symbol" && rules.ownFields.safe ? void 0 : value;
|
|
1545
1706
|
}
|
|
1546
1707
|
if (depth2 > REDACT_MAX_TRAVERSAL_DEPTH) {
|
|
1547
1708
|
return REDACT_DEPTH_EXCEEDED;
|
|
@@ -1552,7 +1713,7 @@ function walk(value, rules, depth2, ancestors, honorToJson = true, inSerialized
|
|
|
1552
1713
|
if (ancestors.has(value)) {
|
|
1553
1714
|
return REDACT_CIRCULAR;
|
|
1554
1715
|
}
|
|
1555
|
-
if (value
|
|
1716
|
+
if (isError(value)) {
|
|
1556
1717
|
return walkError(value, rules, depth2, ancestors, honorToJson, inSerialized);
|
|
1557
1718
|
}
|
|
1558
1719
|
return walkObject(value, rules, depth2, ancestors, honorToJson, inSerialized);
|
|
@@ -1562,17 +1723,26 @@ function walkError(error, rules, depth2, ancestors, honorToJson, inSerialized) {
|
|
|
1562
1723
|
return walkObject(error, rules, depth2, ancestors, honorToJson, inSerialized);
|
|
1563
1724
|
} catch {
|
|
1564
1725
|
rules.visits.count--;
|
|
1565
|
-
return walk(
|
|
1726
|
+
return walk(
|
|
1727
|
+
sanitizeError(error, { ownFields: rules.ownFields }),
|
|
1728
|
+
rules,
|
|
1729
|
+
depth2,
|
|
1730
|
+
ancestors,
|
|
1731
|
+
honorToJson,
|
|
1732
|
+
inSerialized
|
|
1733
|
+
);
|
|
1566
1734
|
}
|
|
1567
1735
|
}
|
|
1568
1736
|
function walkObject(value, rules, depth2, ancestors, honorToJson, inSerialized) {
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
return value;
|
|
1737
|
+
if (ArrayBuffer.isView(value)) {
|
|
1738
|
+
return withBinaryAsSize(value);
|
|
1572
1739
|
}
|
|
1740
|
+
const plain = rules.ownFields.safe;
|
|
1741
|
+
const resolvedToJson = resolveToJson(value, plain);
|
|
1573
1742
|
ancestors.add(value);
|
|
1574
1743
|
try {
|
|
1575
|
-
const
|
|
1744
|
+
const ownsItsForm = rules.ownFields.safe && isError(value);
|
|
1745
|
+
const toJson = honorToJson && !ownsItsForm ? resolvedToJson.method : void 0;
|
|
1576
1746
|
if (toJson !== void 0) {
|
|
1577
1747
|
if (Object.keys(value).some((key) => rules.sensitive.has(key.toLowerCase()))) {
|
|
1578
1748
|
return rules.censor;
|
|
@@ -1580,28 +1750,33 @@ function walkObject(value, rules, depth2, ancestors, honorToJson, inSerialized)
|
|
|
1580
1750
|
return walk(toJson.call(value), rules, depth2 + 1, ancestors, true, inSerialized);
|
|
1581
1751
|
}
|
|
1582
1752
|
if (typeof value === "function") {
|
|
1583
|
-
return value;
|
|
1753
|
+
return plain ? void 0 : value;
|
|
1584
1754
|
}
|
|
1585
1755
|
if (Array.isArray(value)) {
|
|
1586
1756
|
return walkArray(value, rules, depth2, ancestors, inSerialized);
|
|
1587
1757
|
}
|
|
1588
1758
|
const source = value;
|
|
1589
1759
|
const keys = Object.keys(source);
|
|
1590
|
-
const asData = value
|
|
1591
|
-
const clone = value
|
|
1760
|
+
const asData = isError(value) && (plain || rules.errorsAsData && !inSerialized);
|
|
1761
|
+
const clone = isError(value) ? cloneError(value) : void 0;
|
|
1592
1762
|
const copy = clone !== void 0 && !asData ? clone : {};
|
|
1593
|
-
const scrubbed = value
|
|
1763
|
+
const scrubbed = isError(value) && (plain || !inSerialized);
|
|
1764
|
+
const omitted = /* @__PURE__ */ new Set();
|
|
1594
1765
|
for (const key of keys) {
|
|
1595
|
-
const
|
|
1766
|
+
const read = Reflect.get(source, key);
|
|
1767
|
+
const current = scrubbed ? ownFieldForLog(source, key, read, rules.ownFields) : read;
|
|
1596
1768
|
if (current === OMIT_OWN_FIELD) {
|
|
1597
1769
|
Reflect.deleteProperty(copy, key);
|
|
1770
|
+
omitted.add(key);
|
|
1598
1771
|
continue;
|
|
1599
1772
|
}
|
|
1600
1773
|
defineOwn(
|
|
1601
1774
|
copy,
|
|
1602
1775
|
key,
|
|
1603
1776
|
rules.sensitive.has(key.toLowerCase()) ? rules.censor : walk(
|
|
1604
|
-
|
|
1777
|
+
// An own enumerable `name`, `message` or `stack` of an `Error` is the same text as
|
|
1778
|
+
// the part the walk would add, so it is cut the same way.
|
|
1779
|
+
scrubbed && ERROR_TEXT_FIELDS.has(key) ? cutIfText(current) : current,
|
|
1605
1780
|
rules,
|
|
1606
1781
|
depth2 + 1,
|
|
1607
1782
|
ancestors,
|
|
@@ -1610,79 +1785,42 @@ function walkObject(value, rules, depth2, ancestors, honorToJson, inSerialized)
|
|
|
1610
1785
|
)
|
|
1611
1786
|
);
|
|
1612
1787
|
}
|
|
1613
|
-
if (asData)
|
|
1788
|
+
if (asData) {
|
|
1789
|
+
const written = keys.filter((key) => !omitted.has(key));
|
|
1790
|
+
addErrorParts(
|
|
1791
|
+
copy,
|
|
1792
|
+
value,
|
|
1793
|
+
written,
|
|
1794
|
+
errorPartsHost(rules, ancestors, inSerialized),
|
|
1795
|
+
depth2
|
|
1796
|
+
);
|
|
1797
|
+
}
|
|
1614
1798
|
return copy;
|
|
1615
1799
|
} finally {
|
|
1616
1800
|
ancestors.delete(value);
|
|
1617
1801
|
}
|
|
1618
1802
|
}
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
const targets = [];
|
|
1631
|
-
const take = (link) => {
|
|
1632
|
-
if (typeof link === "object" && link !== null) targets.push(link);
|
|
1633
|
-
};
|
|
1634
|
-
if (!Array.isArray(value)) take(value);
|
|
1635
|
-
else for (let index = 0; index < value.length; index++) take(Reflect.get(value, index));
|
|
1636
|
-
return targets;
|
|
1637
|
-
}
|
|
1638
|
-
function walkChainPart(value, level, rules, depth2, ancestors) {
|
|
1639
|
-
const targets = linkTargets(value);
|
|
1640
|
-
if (targets.length > 0 && level + 1 > DEFAULT_MAX_CAUSE_DEPTH) return createDepthMarker();
|
|
1641
|
-
const before = new Map(targets.map((target) => [target, linkDepths.get(target)]));
|
|
1642
|
-
for (const target of targets) linkDepths.set(target, level + 1);
|
|
1643
|
-
try {
|
|
1644
|
-
return walk(value, rules, depth2 + 1, ancestors);
|
|
1645
|
-
} finally {
|
|
1646
|
-
before.forEach((earlier, target) => {
|
|
1647
|
-
if (earlier === void 0) linkDepths.delete(target);
|
|
1648
|
-
else linkDepths.set(target, earlier);
|
|
1649
|
-
});
|
|
1650
|
-
}
|
|
1651
|
-
}
|
|
1652
|
-
function addErrorParts(copy, error, ownKeys, rules, depth2, ancestors) {
|
|
1653
|
-
const taken = new Set(ownKeys);
|
|
1654
|
-
const level = linkDepths.get(error) ?? 0;
|
|
1655
|
-
let incomplete = false;
|
|
1656
|
-
const add = (key, covers, read, write = (value) => walkChainPart(value, level, rules, depth2, ancestors)) => {
|
|
1657
|
-
if (taken.has(key)) return;
|
|
1658
|
-
try {
|
|
1659
|
-
const written = write(read());
|
|
1660
|
-
if (written === void 0) return;
|
|
1661
|
-
const covered = covers.some((name) => rules.sensitive.has(name));
|
|
1662
|
-
defineOwn(copy, key, covered ? rules.censor : written);
|
|
1663
|
-
} catch {
|
|
1664
|
-
incomplete = true;
|
|
1665
|
-
}
|
|
1803
|
+
function errorPartsHost(rules, ancestors, inSerialized) {
|
|
1804
|
+
return {
|
|
1805
|
+
sensitive: rules.sensitive,
|
|
1806
|
+
censor: rules.censor,
|
|
1807
|
+
// What a serializer receives names the error `name`, as the error-like shape it reads does;
|
|
1808
|
+
// everything else keeps the `type` the written entries use.
|
|
1809
|
+
nameKey: inSerialized ? "name" : "type",
|
|
1810
|
+
walk: (value, depth2) => walk(value, rules, depth2, ancestors, true, inSerialized),
|
|
1811
|
+
// Under 'safe' the cap does not read a list's `toJSON`: a list over the cap becomes a fresh array
|
|
1812
|
+
// and is never read for it, and a list within the cap is read once, by the walk.
|
|
1813
|
+
hasToJson: (value) => !rules.ownFields.safe && resolveToJson(value).method !== void 0
|
|
1666
1814
|
};
|
|
1667
|
-
add("type", ["type", "name"], () => error.name);
|
|
1668
|
-
add("message", ["message"], () => error.message);
|
|
1669
|
-
add(
|
|
1670
|
-
"stack",
|
|
1671
|
-
["stack", "name", "message"],
|
|
1672
|
-
() => error.stack,
|
|
1673
|
-
(stack) => typeof stack === "string" ? scrubStack(stack) : void 0
|
|
1674
|
-
);
|
|
1675
|
-
add("cause", ["cause"], () => error.cause);
|
|
1676
|
-
add("errors", ["errors"], () => capErrors(error.errors));
|
|
1677
|
-
if (incomplete && !taken.has(INCOMPLETE_KEY)) defineOwn(copy, INCOMPLETE_KEY, true);
|
|
1678
1815
|
}
|
|
1679
|
-
function createNameRedactor(fieldNames, censor, serializedKeys, maxVisits = REDACT_MAX_VISITS) {
|
|
1816
|
+
function createNameRedactor(fieldNames, censor, serializedKeys, maxVisits = REDACT_MAX_VISITS, ownFields = ALL_OWN_FIELDS) {
|
|
1680
1817
|
const rules = {
|
|
1681
|
-
sensitive: new Set(
|
|
1818
|
+
sensitive: new Set(Array.from(fieldNames, (name) => name.toLowerCase())),
|
|
1682
1819
|
censor,
|
|
1683
1820
|
serializedKeys: new Set(serializedKeys),
|
|
1684
1821
|
errorsAsData: serializedKeys !== void 0,
|
|
1685
|
-
maxVisits
|
|
1822
|
+
maxVisits,
|
|
1823
|
+
ownFields
|
|
1686
1824
|
};
|
|
1687
1825
|
return (value, isRecordRoot = false) => {
|
|
1688
1826
|
try {
|
|
@@ -1859,8 +1997,8 @@ function leafNameOf(path) {
|
|
|
1859
1997
|
}
|
|
1860
1998
|
return leaf;
|
|
1861
1999
|
}
|
|
1862
|
-
function serializeErrorValue(value_) {
|
|
1863
|
-
const sanitized = sanitizeError(value_);
|
|
2000
|
+
function serializeErrorValue(value_, ownFields = ALL_OWN_FIELDS) {
|
|
2001
|
+
const sanitized = sanitizeError(value_, { ownFields });
|
|
1864
2002
|
const serialized = {
|
|
1865
2003
|
// `type` rather than `name`: the field consumers already query.
|
|
1866
2004
|
type: sanitized.name,
|
|
@@ -1885,11 +2023,11 @@ function withSemconvException(record, format) {
|
|
|
1885
2023
|
try {
|
|
1886
2024
|
const candidate = record["err"];
|
|
1887
2025
|
if (typeof candidate?.name === "string") {
|
|
1888
|
-
record["exception.type"] = candidate.name;
|
|
1889
|
-
record["error.type"] = candidate.name;
|
|
2026
|
+
record["exception.type"] = cutText(candidate.name);
|
|
2027
|
+
record["error.type"] = cutText(candidate.name);
|
|
1890
2028
|
}
|
|
1891
2029
|
if (typeof candidate?.message === "string") {
|
|
1892
|
-
record["exception.message"] = candidate.message;
|
|
2030
|
+
record["exception.message"] = cutText(candidate.message);
|
|
1893
2031
|
}
|
|
1894
2032
|
if (typeof candidate?.stack === "string") {
|
|
1895
2033
|
record["exception.stacktrace"] = scrubStack(candidate.stack);
|
|
@@ -1922,20 +2060,28 @@ function withEventName(record, field) {
|
|
|
1922
2060
|
}
|
|
1923
2061
|
var PASS_THROUGH = (value) => value;
|
|
1924
2062
|
function resolveNameRedactor(options) {
|
|
1925
|
-
|
|
1926
|
-
return PASS_THROUGH;
|
|
1927
|
-
}
|
|
1928
|
-
return buildNameRedactor(options, true);
|
|
2063
|
+
return buildNameRedactor(options, true, options.redactStrategy === "names");
|
|
1929
2064
|
}
|
|
1930
|
-
function
|
|
1931
|
-
|
|
2065
|
+
function ownFieldPolicyOf(options) {
|
|
2066
|
+
return createOwnFieldPolicy(options.errorOwnFields, options.errorOwnFieldNames);
|
|
2067
|
+
}
|
|
2068
|
+
function buildNameRedactor(options, nestedErrorsAsData = false, coversNames = true) {
|
|
2069
|
+
const names = coversNames ? [
|
|
1932
2070
|
...options.shouldDisableDefaultRedact ? [] : REDACT_COMMON_FIELDS,
|
|
1933
2071
|
...options.redactPaths.flatMap((path) => leafNameOf(path) ?? [])
|
|
1934
|
-
];
|
|
1935
|
-
|
|
2072
|
+
] : [];
|
|
2073
|
+
const ownFields = ownFieldPolicyOf(options);
|
|
2074
|
+
const walks = names.length > 0 || ownFields.safe;
|
|
2075
|
+
if (!walks && resolveRedactOption(options) === void 0) {
|
|
1936
2076
|
return PASS_THROUGH;
|
|
1937
2077
|
}
|
|
1938
|
-
return nestedErrorsAsData
|
|
2078
|
+
return nestedErrorsAsData && walks ? createNameRedactor(
|
|
2079
|
+
names,
|
|
2080
|
+
options.redactCensor,
|
|
2081
|
+
["err", ...Object.keys(options.serializers)],
|
|
2082
|
+
void 0,
|
|
2083
|
+
ownFields
|
|
2084
|
+
) : createNameRedactor(names, options.redactCensor, void 0, void 0, ownFields);
|
|
1939
2085
|
}
|
|
1940
2086
|
function resolveRedactOption(options) {
|
|
1941
2087
|
const paths = options.redactStrategy === "paths" ? compileRedactPaths(options.redactPaths, options.shouldDisableDefaultRedact) : [...new Set(options.redactPaths)];
|
|
@@ -1948,9 +2094,10 @@ function buildPinoInstance(options, logContext, destinations, health) {
|
|
|
1948
2094
|
const maxBytes = options.maxEntrySizeBytes;
|
|
1949
2095
|
const redactRecord = resolveNameRedactor(options);
|
|
1950
2096
|
const redactSerialized = buildNameRedactor(options);
|
|
2097
|
+
const ownFields = ownFieldPolicyOf(options);
|
|
1951
2098
|
const bound = (serializer) => createSizeBoundedSerializer((input) => redactSerialized(serializer(input)), maxBytes);
|
|
1952
2099
|
const serializers = {
|
|
1953
|
-
err: bound(serializeErrorValue),
|
|
2100
|
+
err: bound((error) => serializeErrorValue(error, ownFields)),
|
|
1954
2101
|
...Object.fromEntries(
|
|
1955
2102
|
Object.entries(options.serializers).map(
|
|
1956
2103
|
([key, serializer]) => [key, bound(serializer)]
|
|
@@ -2451,7 +2598,7 @@ var DestinationRegistry = class {
|
|
|
2451
2598
|
let detail = "UnknownError";
|
|
2452
2599
|
try {
|
|
2453
2600
|
const stack = isErrorLike(cause) ? cause.stack : void 0;
|
|
2454
|
-
detail = stack === void 0 ?
|
|
2601
|
+
detail = stack === void 0 ? toBoundedMessage(isErrorLike(cause) ? String(cause.message) : String(cause)) : escapeControlCharacters(cutText(String(stack)));
|
|
2455
2602
|
} catch {
|
|
2456
2603
|
}
|
|
2457
2604
|
writeStderrSafely(`[DestinationRegistry] Shutdown failed for "${name}": ${detail}
|
|
@@ -2794,7 +2941,7 @@ function isPinoPrettyMissing(cause) {
|
|
|
2794
2941
|
}
|
|
2795
2942
|
function describeFailure(cause) {
|
|
2796
2943
|
try {
|
|
2797
|
-
return
|
|
2944
|
+
return toBoundedMessage(isError(cause) ? cause.message : String(cause));
|
|
2798
2945
|
} catch {
|
|
2799
2946
|
return "unreadable value";
|
|
2800
2947
|
}
|
|
@@ -3098,7 +3245,7 @@ exports.HttpAccessLogMiddleware = class HttpAccessLogMiddleware {
|
|
|
3098
3245
|
RESERVED_LOG_KEYS.HTTP_REQUEST_CLIENT_ERROR,
|
|
3099
3246
|
`${method} ${url} \u2192 ${statusCode}`,
|
|
3100
3247
|
userId,
|
|
3101
|
-
recorded === void 0 ? meta : { ...meta, errorMessage: recorded.error.message }
|
|
3248
|
+
recorded === void 0 ? meta : { ...meta, errorMessage: cutIfText(recorded.error.message) }
|
|
3102
3249
|
);
|
|
3103
3250
|
return;
|
|
3104
3251
|
}
|