@bymax-one/nest-logger 1.4.9 → 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 +106 -1
- package/README.md +44 -23
- package/dist/server/index.cjs +325 -167
- package/dist/server/index.d.cts +23 -1
- package/dist/server/index.d.ts +23 -1
- package/dist/server/index.mjs +325 -167
- package/package.json +1 -1
package/dist/server/index.mjs
CHANGED
|
@@ -80,6 +80,8 @@ function applyDefaults(options) {
|
|
|
80
80
|
}),
|
|
81
81
|
otel: Object.freeze(otel),
|
|
82
82
|
maxEntrySizeBytes: options.maxEntrySizeBytes ?? DEFAULT_MAX_ENTRY_SIZE_BYTES,
|
|
83
|
+
errorOwnFields: options.errorOwnFields ?? "all",
|
|
84
|
+
errorOwnFieldNames: Object.freeze([...options.errorOwnFieldNames ?? []]),
|
|
83
85
|
serializers: Object.freeze({ ...options.serializers ?? {} }),
|
|
84
86
|
timestamp: options.timestamp ?? (() => (/* @__PURE__ */ new Date()).toISOString())
|
|
85
87
|
};
|
|
@@ -224,6 +226,20 @@ function validateCustomization(options) {
|
|
|
224
226
|
}
|
|
225
227
|
}
|
|
226
228
|
}
|
|
229
|
+
function validateErrorFields(options) {
|
|
230
|
+
const mode = options.errorOwnFields;
|
|
231
|
+
if (mode !== void 0 && mode !== "all" && mode !== "safe") {
|
|
232
|
+
reject("errorOwnFields", "must be 'all' or 'safe'", mode);
|
|
233
|
+
}
|
|
234
|
+
const names = options.errorOwnFieldNames;
|
|
235
|
+
if (names === void 0) return;
|
|
236
|
+
if (!Array.isArray(names)) reject("errorOwnFieldNames", "must be an array of strings", names);
|
|
237
|
+
names.forEach((entry, index) => {
|
|
238
|
+
if (!isNonEmptyString(entry)) {
|
|
239
|
+
reject(`errorOwnFieldNames[${String(index)}]`, "must be a non-empty string", entry);
|
|
240
|
+
}
|
|
241
|
+
});
|
|
242
|
+
}
|
|
227
243
|
var UNREADABLE = /* @__PURE__ */ Symbol("unreadable");
|
|
228
244
|
function readMember(destination, key) {
|
|
229
245
|
try {
|
|
@@ -295,6 +311,7 @@ function validateOptions(options) {
|
|
|
295
311
|
validateCore(options);
|
|
296
312
|
validateClosedSets(options);
|
|
297
313
|
validateCustomization(options);
|
|
314
|
+
validateErrorFields(options);
|
|
298
315
|
validateDestinations(options);
|
|
299
316
|
validateHttp(options);
|
|
300
317
|
validateOtel(options);
|
|
@@ -350,6 +367,20 @@ var PROTOTYPE_POLLUTING_KEYS = /* @__PURE__ */ new Set([
|
|
|
350
367
|
"prototype"
|
|
351
368
|
]);
|
|
352
369
|
|
|
370
|
+
// src/server/utils/bounded-text.util.ts
|
|
371
|
+
var MAX_TEXT_LENGTH = 16384;
|
|
372
|
+
var TEXT_TRUNCATED = "\u2026[truncated]";
|
|
373
|
+
function cutIfText(value) {
|
|
374
|
+
return typeof value === "string" ? cutText(value) : value;
|
|
375
|
+
}
|
|
376
|
+
function cutText(text, alreadyCut = false) {
|
|
377
|
+
if (!alreadyCut && text.length <= MAX_TEXT_LENGTH) return text;
|
|
378
|
+
const head = text.slice(0, MAX_TEXT_LENGTH);
|
|
379
|
+
const last = head.charCodeAt(head.length - 1);
|
|
380
|
+
const whole = last >= 55296 && last <= 56319 ? head.slice(0, -1) : head;
|
|
381
|
+
return whole + TEXT_TRUNCATED;
|
|
382
|
+
}
|
|
383
|
+
|
|
353
384
|
// src/server/utils/escape-log-text.util.ts
|
|
354
385
|
var LINE_TERMINATORS = /* @__PURE__ */ new Set(["\r", "\n", "\x85", "\u2028", "\u2029"]);
|
|
355
386
|
var UNSAFE_IN_SINGLE_LINE = /[\u0000-\u0008\u000A-\u001F\u007F-\u009F\u2028\u2029]/g;
|
|
@@ -363,14 +394,35 @@ function toSingleLineMessage(text) {
|
|
|
363
394
|
(char) => LINE_TERMINATORS.has(char) ? "\\n" : toEscapeSequence(char)
|
|
364
395
|
);
|
|
365
396
|
}
|
|
397
|
+
function toBoundedMessage(text) {
|
|
398
|
+
return cutText(toSingleLineMessage(text));
|
|
399
|
+
}
|
|
366
400
|
function escapeControlCharacters(text) {
|
|
367
401
|
return text.replace(UNSAFE_IN_MULTILINE, toEscapeSequence);
|
|
368
402
|
}
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
403
|
+
function isError(value) {
|
|
404
|
+
try {
|
|
405
|
+
return types.isNativeError(value) || value instanceof Error;
|
|
406
|
+
} catch {
|
|
407
|
+
return false;
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
var DEFAULT_SAFE_ERROR_FIELDS = [
|
|
411
|
+
"code",
|
|
412
|
+
"errno",
|
|
413
|
+
"syscall",
|
|
414
|
+
"signal",
|
|
415
|
+
"status",
|
|
416
|
+
"statusCode",
|
|
417
|
+
"address",
|
|
418
|
+
"port",
|
|
419
|
+
"hostname",
|
|
420
|
+
"constraint",
|
|
421
|
+
"table",
|
|
422
|
+
"column",
|
|
423
|
+
"schema",
|
|
424
|
+
"routine"
|
|
425
|
+
];
|
|
374
426
|
var DERIVED_ERROR_FIELDS = /* @__PURE__ */ new Set([
|
|
375
427
|
"name",
|
|
376
428
|
"message",
|
|
@@ -378,15 +430,47 @@ var DERIVED_ERROR_FIELDS = /* @__PURE__ */ new Set([
|
|
|
378
430
|
"cause",
|
|
379
431
|
"errors"
|
|
380
432
|
]);
|
|
433
|
+
var ALL_OWN_FIELDS = { safe: false, names: /* @__PURE__ */ new Set() };
|
|
434
|
+
function createOwnFieldPolicy(mode, extraNames) {
|
|
435
|
+
if (mode === "all") return ALL_OWN_FIELDS;
|
|
436
|
+
return { safe: true, names: /* @__PURE__ */ new Set([...DEFAULT_SAFE_ERROR_FIELDS, ...extraNames]) };
|
|
437
|
+
}
|
|
438
|
+
function allowsOwnField(policy, key) {
|
|
439
|
+
return !policy.safe || DERIVED_ERROR_FIELDS.has(key) || key === "_errorFieldsIncomplete" || policy.names.has(key);
|
|
440
|
+
}
|
|
441
|
+
var TYPED_ARRAY_BYTE_LENGTH = Reflect.getOwnPropertyDescriptor(
|
|
442
|
+
Object.getPrototypeOf(Uint8Array.prototype),
|
|
443
|
+
"byteLength"
|
|
444
|
+
)?.get;
|
|
445
|
+
var DATA_VIEW_BYTE_LENGTH = Reflect.getOwnPropertyDescriptor(DataView.prototype, "byteLength")?.get;
|
|
446
|
+
function binaryMarker(view) {
|
|
447
|
+
const size = types.isDataView(view) ? DATA_VIEW_BYTE_LENGTH.call(view) : TYPED_ARRAY_BYTE_LENGTH.call(view);
|
|
448
|
+
return `[Binary ${size} bytes]`;
|
|
449
|
+
}
|
|
450
|
+
function withBinaryAsSize(value) {
|
|
451
|
+
if (ArrayBuffer.isView(value)) return binaryMarker(value);
|
|
452
|
+
if (!Array.isArray(value) || !value.some((member) => ArrayBuffer.isView(member))) return value;
|
|
453
|
+
return value.map(
|
|
454
|
+
(member) => ArrayBuffer.isView(member) ? binaryMarker(member) : member
|
|
455
|
+
);
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
// src/server/utils/sanitize-error.util.ts
|
|
459
|
+
var DEFAULT_MAX_CAUSE_DEPTH = 3;
|
|
460
|
+
var MAX_AGGREGATE_ERRORS = 10;
|
|
461
|
+
var CIRCULAR_SENTINEL = "[Circular]";
|
|
381
462
|
function sanitizeError(err, options) {
|
|
382
|
-
const maxCauseDepth = DEFAULT_MAX_CAUSE_DEPTH;
|
|
383
|
-
return toSanitizedError(err, /* @__PURE__ */ new WeakSet(), 0,
|
|
463
|
+
const maxCauseDepth = options?.maxCauseDepth ?? DEFAULT_MAX_CAUSE_DEPTH;
|
|
464
|
+
return toSanitizedError(err, /* @__PURE__ */ new WeakSet(), 0, {
|
|
465
|
+
maxDepth: maxCauseDepth,
|
|
466
|
+
ownFields: options?.ownFields ?? ALL_OWN_FIELDS
|
|
467
|
+
});
|
|
384
468
|
}
|
|
385
469
|
function isErrorLike(value) {
|
|
386
470
|
try {
|
|
387
471
|
return readsAsError(value);
|
|
388
472
|
} catch {
|
|
389
|
-
return
|
|
473
|
+
return isError(value);
|
|
390
474
|
}
|
|
391
475
|
}
|
|
392
476
|
function readsAsError(value) {
|
|
@@ -396,40 +480,32 @@ function readsAsError(value) {
|
|
|
396
480
|
const candidate = value;
|
|
397
481
|
return typeof candidate.name === "string" && typeof candidate.message === "string";
|
|
398
482
|
}
|
|
399
|
-
function
|
|
400
|
-
try {
|
|
401
|
-
return value instanceof Error;
|
|
402
|
-
} catch {
|
|
403
|
-
return false;
|
|
404
|
-
}
|
|
405
|
-
}
|
|
406
|
-
function toSanitizedError(value, seen, depth2, maxDepth) {
|
|
483
|
+
function toSanitizedError(value, seen, depth2, walk2) {
|
|
407
484
|
try {
|
|
408
485
|
if (!readsAsError(value)) {
|
|
409
|
-
return { name: "UnknownError", message: String(value) };
|
|
486
|
+
return { name: "UnknownError", message: cutText(String(value)) };
|
|
410
487
|
}
|
|
411
488
|
seen.add(value);
|
|
412
|
-
const result = { name: value.name, message: value.message };
|
|
489
|
+
const result = { name: cutText(value.name), message: cutText(value.message) };
|
|
413
490
|
const stack = readOptional(() => value.stack, result);
|
|
414
491
|
if (stack !== void 0) {
|
|
415
492
|
result.stack = scrubStack(stack);
|
|
416
493
|
}
|
|
417
|
-
const isAtDepthLimit = depth2 >= maxDepth;
|
|
494
|
+
const isAtDepthLimit = depth2 >= walk2.maxDepth;
|
|
418
495
|
const cause = readOptional(() => value.cause, result);
|
|
419
496
|
if (cause !== void 0) {
|
|
420
|
-
result.cause = isAtDepthLimit ? createDepthMarker() : toSanitizedChild(cause, seen, depth2 + 1,
|
|
497
|
+
result.cause = isAtDepthLimit ? createDepthMarker() : toSanitizedChild(cause, seen, depth2 + 1, walk2);
|
|
421
498
|
}
|
|
422
499
|
const aggregated = readAggregatedErrors(value);
|
|
423
500
|
if (aggregated !== void 0) {
|
|
424
501
|
const capped = aggregated.slice(0, MAX_AGGREGATE_ERRORS);
|
|
425
502
|
result.errors = capped.map(
|
|
426
|
-
(inner) => isAtDepthLimit ? createDepthMarker() : toSanitizedChild(inner, seen, depth2 + 1,
|
|
503
|
+
(inner) => isAtDepthLimit ? createDepthMarker() : toSanitizedChild(inner, seen, depth2 + 1, walk2)
|
|
427
504
|
);
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
}
|
|
505
|
+
const left = carriedOmitted(aggregated) || aggregated.length - MAX_AGGREGATE_ERRORS;
|
|
506
|
+
if (left > 0) result.errors.push(createWidthMarker(left));
|
|
431
507
|
}
|
|
432
|
-
assignOwnErrorFields(result, value);
|
|
508
|
+
assignOwnErrorFields(result, value, walk2.ownFields);
|
|
433
509
|
return result;
|
|
434
510
|
} catch {
|
|
435
511
|
return { name: "SanitizeFailed", message: "Failed to sanitize the thrown value" };
|
|
@@ -437,28 +513,33 @@ function toSanitizedError(value, seen, depth2, maxDepth) {
|
|
|
437
513
|
}
|
|
438
514
|
var ARGUMENT_FIELDS = /* @__PURE__ */ new Set(["args", "parameters"]);
|
|
439
515
|
var DATABASE_VALUE_FIELDS = /* @__PURE__ */ new Set(["detail", "where", "internalQuery"]);
|
|
440
|
-
var SQLSTATE = /^[0-9A-Z]{
|
|
516
|
+
var SQLSTATE = /^[0-9A-DF-Z][0-9A-Z]{4}$/;
|
|
441
517
|
var OMIT_OWN_FIELD = /* @__PURE__ */ Symbol("omit-own-field");
|
|
442
518
|
function isDatabaseError(source) {
|
|
443
|
-
const
|
|
444
|
-
|
|
445
|
-
return typeof own("severity") === "string" && typeof own("routine") === "string" && typeof code === "string" && SQLSTATE.test(code);
|
|
519
|
+
const code = Object.getOwnPropertyDescriptor(source, "code")?.value;
|
|
520
|
+
return typeof code === "string" && SQLSTATE.test(code);
|
|
446
521
|
}
|
|
447
|
-
function ownFieldForLog(source, key, value) {
|
|
522
|
+
function ownFieldForLog(source, key, value, policy = ALL_OWN_FIELDS) {
|
|
523
|
+
if (!allowsOwnField(policy, key)) return OMIT_OWN_FIELD;
|
|
448
524
|
if (ARGUMENT_FIELDS.has(key.toLowerCase())) return OMIT_OWN_FIELD;
|
|
449
525
|
if (DATABASE_VALUE_FIELDS.has(key) && isDatabaseError(source)) return OMIT_OWN_FIELD;
|
|
450
|
-
if (key !== "command" || typeof value !== "object" || value === null)
|
|
526
|
+
if (key !== "command" || typeof value !== "object" || value === null) {
|
|
527
|
+
return withBinaryAsSize(value);
|
|
528
|
+
}
|
|
451
529
|
const name = Object.getOwnPropertyDescriptor(value, "name")?.value;
|
|
452
530
|
return typeof name === "string" ? { name } : OMIT_OWN_FIELD;
|
|
453
531
|
}
|
|
454
|
-
function
|
|
532
|
+
function defineErrorField(target, key, value) {
|
|
533
|
+
Object.defineProperty(target, key, { value, enumerable: true });
|
|
534
|
+
}
|
|
535
|
+
function assignOwnErrorFields(target, source, policy = ALL_OWN_FIELDS) {
|
|
455
536
|
try {
|
|
456
537
|
const own = Array.isArray(source) ? {} : source;
|
|
457
538
|
for (const [key, field] of Object.entries(own)) {
|
|
458
|
-
const value = ownFieldForLog(own, key, field);
|
|
539
|
+
const value = ownFieldForLog(own, key, field, policy);
|
|
459
540
|
if (value === OMIT_OWN_FIELD) continue;
|
|
460
541
|
if (!Object.hasOwn(target, key) && !DERIVED_ERROR_FIELDS.has(key)) {
|
|
461
|
-
|
|
542
|
+
defineErrorField(target, key, value);
|
|
462
543
|
}
|
|
463
544
|
}
|
|
464
545
|
} catch {
|
|
@@ -476,20 +557,32 @@ function readOptional(read, node) {
|
|
|
476
557
|
return void 0;
|
|
477
558
|
}
|
|
478
559
|
}
|
|
479
|
-
function toSanitizedChild(value, seen, depth2,
|
|
560
|
+
function toSanitizedChild(value, seen, depth2, walk2) {
|
|
480
561
|
if (isObject(value) && seen.has(value)) {
|
|
481
562
|
return CIRCULAR_SENTINEL;
|
|
482
563
|
}
|
|
483
|
-
return toSanitizedError(value, seen, depth2,
|
|
564
|
+
return toSanitizedError(value, seen, depth2, walk2);
|
|
565
|
+
}
|
|
566
|
+
function carriedOmitted(list) {
|
|
567
|
+
if (list.length > MAX_AGGREGATE_ERRORS + 1) return 0;
|
|
568
|
+
try {
|
|
569
|
+
const cut = list.at(MAX_AGGREGATE_ERRORS);
|
|
570
|
+
const omitted = cut?._truncated === true ? cut._omitted : void 0;
|
|
571
|
+
return Number.isInteger(omitted) ? Math.max(omitted, 0) : 0;
|
|
572
|
+
} catch {
|
|
573
|
+
return 0;
|
|
574
|
+
}
|
|
484
575
|
}
|
|
485
576
|
function readAggregatedErrors(value) {
|
|
486
577
|
const candidate = value.errors;
|
|
487
578
|
return Array.isArray(candidate) ? candidate : void 0;
|
|
488
579
|
}
|
|
580
|
+
var MAX_STACK_SCAN = 8 * MAX_TEXT_LENGTH;
|
|
489
581
|
function scrubStack(stack) {
|
|
490
|
-
|
|
491
|
-
stack.split("\n").filter((line) => !line.includes("node_modules")).join("\n")
|
|
582
|
+
const scrubbed = escapeControlCharacters(
|
|
583
|
+
stack.slice(0, MAX_STACK_SCAN).split("\n").filter((line) => !line.includes("node_modules")).join("\n")
|
|
492
584
|
);
|
|
585
|
+
return cutText(scrubbed, stack.length > MAX_STACK_SCAN);
|
|
493
586
|
}
|
|
494
587
|
function isObject(value) {
|
|
495
588
|
return typeof value === "object" && value !== null;
|
|
@@ -524,14 +617,14 @@ function withoutOwnedKeys(metadata) {
|
|
|
524
617
|
}
|
|
525
618
|
function safeErrorMessage(error) {
|
|
526
619
|
try {
|
|
527
|
-
return
|
|
620
|
+
return toBoundedMessage(String(error.message));
|
|
528
621
|
} catch {
|
|
529
622
|
return "Unreadable error message";
|
|
530
623
|
}
|
|
531
624
|
}
|
|
532
625
|
function safeLogMessage(message) {
|
|
533
626
|
try {
|
|
534
|
-
return
|
|
627
|
+
return toBoundedMessage(typeof message === "string" ? message : String(message));
|
|
535
628
|
} catch {
|
|
536
629
|
return "Unreadable log message";
|
|
537
630
|
}
|
|
@@ -605,7 +698,7 @@ var PinoLoggerService = class {
|
|
|
605
698
|
const context = typeof optionalParams[1] === "string" ? optionalParams[1] : this.context;
|
|
606
699
|
const payload = {};
|
|
607
700
|
assignIfDefined(payload, "context", context);
|
|
608
|
-
assignIfDefined(payload, "stack", stack);
|
|
701
|
+
assignIfDefined(payload, "stack", stack === void 0 ? stack : cutText(stack));
|
|
609
702
|
assignIfDefined(payload, "err", findErrorParam(optionalParams));
|
|
610
703
|
this.pino.error(payload, safeLogMessage(message));
|
|
611
704
|
}
|
|
@@ -751,7 +844,7 @@ var PinoLoggerService = class {
|
|
|
751
844
|
const payload = { ...withoutOwnedKeys(metadata), logKey };
|
|
752
845
|
assignIfDefined(payload, "userId", userId);
|
|
753
846
|
assignIfDefined(payload, "context", this.context);
|
|
754
|
-
const line =
|
|
847
|
+
const line = toBoundedMessage(message);
|
|
755
848
|
if (level === "info") {
|
|
756
849
|
this.pino.info(payload, line);
|
|
757
850
|
} else {
|
|
@@ -984,7 +1077,7 @@ function readRecordedError(req) {
|
|
|
984
1077
|
return Reflect.get(req, RECORDED_ERROR);
|
|
985
1078
|
}
|
|
986
1079
|
function toError(thrown) {
|
|
987
|
-
return thrown
|
|
1080
|
+
return isError(thrown) ? thrown : new Error(String(thrown));
|
|
988
1081
|
}
|
|
989
1082
|
function readUserId(req) {
|
|
990
1083
|
return req.user?.sub ?? req.user?.id;
|
|
@@ -1145,7 +1238,7 @@ var HttpLoggingInterceptor = class {
|
|
|
1145
1238
|
RESERVED_LOG_KEYS.HTTP_REQUEST_CLIENT_ERROR,
|
|
1146
1239
|
`${method} ${url} \u2192 ${statusCode}`,
|
|
1147
1240
|
userId,
|
|
1148
|
-
{ method, url, statusCode, duration, errorMessage: err.message }
|
|
1241
|
+
{ method, url, statusCode, duration, errorMessage: cutIfText(err.message) }
|
|
1149
1242
|
);
|
|
1150
1243
|
}
|
|
1151
1244
|
return;
|
|
@@ -1275,10 +1368,10 @@ function reportDestinationFailure(logKey, name, cause, msg) {
|
|
|
1275
1368
|
var UNREADABLE_CAUSE = { type: "UnknownError", message: "unreadable value" };
|
|
1276
1369
|
function describeCause(cause) {
|
|
1277
1370
|
try {
|
|
1278
|
-
return cause
|
|
1279
|
-
type:
|
|
1280
|
-
message:
|
|
1281
|
-
} : { type: "UnknownError", message:
|
|
1371
|
+
return isError(cause) ? {
|
|
1372
|
+
type: toBoundedMessage(String(cause.name)),
|
|
1373
|
+
message: toBoundedMessage(String(cause.message))
|
|
1374
|
+
} : { type: "UnknownError", message: toBoundedMessage(String(cause)) };
|
|
1282
1375
|
} catch {
|
|
1283
1376
|
return UNREADABLE_CAUSE;
|
|
1284
1377
|
}
|
|
@@ -1468,27 +1561,114 @@ function destinationToStream(destination, health) {
|
|
|
1468
1561
|
});
|
|
1469
1562
|
}
|
|
1470
1563
|
|
|
1564
|
+
// src/server/utils/redact-error-parts.util.ts
|
|
1565
|
+
function defineOwn(target, key, value) {
|
|
1566
|
+
Reflect.defineProperty(target, key, { value, enumerable: true });
|
|
1567
|
+
}
|
|
1568
|
+
var linkDepths = /* @__PURE__ */ new WeakMap();
|
|
1569
|
+
var ERROR_TEXT_FIELDS = /* @__PURE__ */ new Set(["name", "message", "stack"]);
|
|
1570
|
+
var INCOMPLETE_KEY = "_errorFieldsIncomplete";
|
|
1571
|
+
var widthMarkers = /* @__PURE__ */ new WeakSet();
|
|
1572
|
+
function capErrors(errors, host) {
|
|
1573
|
+
if (!Array.isArray(errors) || errors.length <= MAX_AGGREGATE_ERRORS) return errors;
|
|
1574
|
+
if (host.hasToJson(errors)) return errors;
|
|
1575
|
+
const kept = [];
|
|
1576
|
+
for (let index = 0; index < MAX_AGGREGATE_ERRORS; index++) kept.push(Reflect.get(errors, index));
|
|
1577
|
+
const marker = createWidthMarker(errors.length - MAX_AGGREGATE_ERRORS);
|
|
1578
|
+
widthMarkers.add(marker);
|
|
1579
|
+
kept.push(marker);
|
|
1580
|
+
return kept;
|
|
1581
|
+
}
|
|
1582
|
+
function linkTargets(value) {
|
|
1583
|
+
const targets = [];
|
|
1584
|
+
const take = (link) => {
|
|
1585
|
+
if (typeof link === "object" && link !== null) targets.push(link);
|
|
1586
|
+
};
|
|
1587
|
+
if (!Array.isArray(value)) take(value);
|
|
1588
|
+
else for (let index = 0; index < value.length; index++) take(Reflect.get(value, index));
|
|
1589
|
+
return targets;
|
|
1590
|
+
}
|
|
1591
|
+
function walkChainPart(value, level, host, depth2) {
|
|
1592
|
+
const targets = linkTargets(value);
|
|
1593
|
+
if (targets.length > 0 && level + 1 > DEFAULT_MAX_CAUSE_DEPTH) {
|
|
1594
|
+
if (Array.isArray(value) && host.nameKey === "name") {
|
|
1595
|
+
return Array.from({ length: value.length }, (_member, index) => {
|
|
1596
|
+
const member = Reflect.get(value, index);
|
|
1597
|
+
return typeof member === "object" && member !== null && widthMarkers.has(member) ? member : createDepthMarker();
|
|
1598
|
+
});
|
|
1599
|
+
}
|
|
1600
|
+
return createDepthMarker();
|
|
1601
|
+
}
|
|
1602
|
+
const before = new Map(targets.map((target) => [target, linkDepths.get(target)]));
|
|
1603
|
+
for (const target of targets) linkDepths.set(target, level + 1);
|
|
1604
|
+
try {
|
|
1605
|
+
return host.walk(value, depth2 + 1);
|
|
1606
|
+
} finally {
|
|
1607
|
+
before.forEach((earlier, target) => {
|
|
1608
|
+
if (earlier === void 0) linkDepths.delete(target);
|
|
1609
|
+
else linkDepths.set(target, earlier);
|
|
1610
|
+
});
|
|
1611
|
+
}
|
|
1612
|
+
}
|
|
1613
|
+
function cutOrWalk(value, level, host, depth2) {
|
|
1614
|
+
return typeof value === "string" ? cutText(value) : walkChainPart(value, level, host, depth2);
|
|
1615
|
+
}
|
|
1616
|
+
function addErrorParts(copy, error, ownKeys, host, depth2) {
|
|
1617
|
+
const taken = new Set(ownKeys);
|
|
1618
|
+
const level = linkDepths.get(error) ?? 0;
|
|
1619
|
+
let incomplete = false;
|
|
1620
|
+
const add = (key, covers, read, write = (value) => walkChainPart(value, level, host, depth2)) => {
|
|
1621
|
+
if (taken.has(key)) return;
|
|
1622
|
+
try {
|
|
1623
|
+
const written = write(read());
|
|
1624
|
+
if (written === void 0) return;
|
|
1625
|
+
const covered = covers.some((name) => host.sensitive.has(name));
|
|
1626
|
+
defineOwn(copy, key, covered ? host.censor : written);
|
|
1627
|
+
} catch {
|
|
1628
|
+
incomplete = true;
|
|
1629
|
+
}
|
|
1630
|
+
};
|
|
1631
|
+
add(
|
|
1632
|
+
host.nameKey,
|
|
1633
|
+
[host.nameKey, "name"],
|
|
1634
|
+
() => error.name,
|
|
1635
|
+
(name) => cutOrWalk(name, level, host, depth2)
|
|
1636
|
+
);
|
|
1637
|
+
add(
|
|
1638
|
+
"message",
|
|
1639
|
+
["message"],
|
|
1640
|
+
() => error.message,
|
|
1641
|
+
(message) => cutOrWalk(message, level, host, depth2)
|
|
1642
|
+
);
|
|
1643
|
+
add(
|
|
1644
|
+
"stack",
|
|
1645
|
+
["stack", "name", "message"],
|
|
1646
|
+
() => error.stack,
|
|
1647
|
+
(stack) => typeof stack === "string" ? scrubStack(stack) : void 0
|
|
1648
|
+
);
|
|
1649
|
+
add("cause", ["cause"], () => error.cause);
|
|
1650
|
+
add("errors", ["errors"], () => capErrors(error.errors, host));
|
|
1651
|
+
if (incomplete && !taken.has(INCOMPLETE_KEY)) defineOwn(copy, INCOMPLETE_KEY, true);
|
|
1652
|
+
}
|
|
1653
|
+
|
|
1471
1654
|
// src/server/utils/redact-by-name.util.ts
|
|
1472
1655
|
var REDACT_MAX_TRAVERSAL_DEPTH = 100;
|
|
1473
1656
|
var REDACT_DEPTH_EXCEEDED = "[REDACTION_DEPTH_EXCEEDED]";
|
|
1657
|
+
var REDACT_MAX_VISITS = 2e5;
|
|
1658
|
+
var REDACT_BUDGET_EXCEEDED = "[REDACTION_BUDGET_EXCEEDED]";
|
|
1474
1659
|
var REDACT_CIRCULAR = "[Circular]";
|
|
1475
|
-
function resolveToJson(value) {
|
|
1476
|
-
let
|
|
1477
|
-
let
|
|
1478
|
-
let current = value;
|
|
1660
|
+
function resolveToJson(value, viaGet = false) {
|
|
1661
|
+
let candidate = viaGet ? Reflect.get(value, "toJSON") : void 0;
|
|
1662
|
+
let current = viaGet ? null : value;
|
|
1479
1663
|
while (current !== null) {
|
|
1480
1664
|
const descriptor = Object.getOwnPropertyDescriptor(current, "toJSON");
|
|
1481
1665
|
if (descriptor !== void 0) {
|
|
1482
|
-
|
|
1483
|
-
candidate = getter === void 0 ? descriptor.value : getter.call(value);
|
|
1666
|
+
candidate = descriptor.get === void 0 ? descriptor.value : descriptor.get.call(value);
|
|
1484
1667
|
break;
|
|
1485
1668
|
}
|
|
1486
1669
|
current = Object.getPrototypeOf(current);
|
|
1487
1670
|
}
|
|
1488
|
-
return {
|
|
1489
|
-
method: typeof candidate === "function" ? candidate : void 0,
|
|
1490
|
-
fromAccessor: getter !== void 0
|
|
1491
|
-
};
|
|
1671
|
+
return { method: typeof candidate === "function" ? candidate : void 0 };
|
|
1492
1672
|
}
|
|
1493
1673
|
function cloneError(error) {
|
|
1494
1674
|
const descriptors = Object.getOwnPropertyDescriptors(error);
|
|
@@ -1502,10 +1682,6 @@ function cloneError(error) {
|
|
|
1502
1682
|
}
|
|
1503
1683
|
return clone;
|
|
1504
1684
|
}
|
|
1505
|
-
var BUFFER_TO_JSON = Buffer.prototype.toJSON;
|
|
1506
|
-
function defineOwn(target, key, value) {
|
|
1507
|
-
Reflect.defineProperty(target, key, { value, enumerable: true });
|
|
1508
|
-
}
|
|
1509
1685
|
function walkArray(value, rules, depth2, ancestors, inSerialized) {
|
|
1510
1686
|
const length = value.length;
|
|
1511
1687
|
const copy = [];
|
|
@@ -1518,20 +1694,23 @@ function walkArray(value, rules, depth2, ancestors, inSerialized) {
|
|
|
1518
1694
|
}
|
|
1519
1695
|
return copy;
|
|
1520
1696
|
}
|
|
1521
|
-
function walk(value, rules, depth2, ancestors, honorToJson
|
|
1697
|
+
function walk(value, rules, depth2, ancestors, honorToJson, inSerialized = false) {
|
|
1522
1698
|
if (value === null) {
|
|
1523
1699
|
return value;
|
|
1524
1700
|
}
|
|
1525
1701
|
if (typeof value !== "object" && typeof value !== "function") {
|
|
1526
|
-
return value;
|
|
1702
|
+
return typeof value === "symbol" && rules.ownFields.safe ? void 0 : value;
|
|
1527
1703
|
}
|
|
1528
1704
|
if (depth2 > REDACT_MAX_TRAVERSAL_DEPTH) {
|
|
1529
1705
|
return REDACT_DEPTH_EXCEEDED;
|
|
1530
1706
|
}
|
|
1707
|
+
if (++rules.visits.count > rules.maxVisits) {
|
|
1708
|
+
return REDACT_BUDGET_EXCEEDED;
|
|
1709
|
+
}
|
|
1531
1710
|
if (ancestors.has(value)) {
|
|
1532
1711
|
return REDACT_CIRCULAR;
|
|
1533
1712
|
}
|
|
1534
|
-
if (value
|
|
1713
|
+
if (isError(value)) {
|
|
1535
1714
|
return walkError(value, rules, depth2, ancestors, honorToJson, inSerialized);
|
|
1536
1715
|
}
|
|
1537
1716
|
return walkObject(value, rules, depth2, ancestors, honorToJson, inSerialized);
|
|
@@ -1540,17 +1719,27 @@ function walkError(error, rules, depth2, ancestors, honorToJson, inSerialized) {
|
|
|
1540
1719
|
try {
|
|
1541
1720
|
return walkObject(error, rules, depth2, ancestors, honorToJson, inSerialized);
|
|
1542
1721
|
} catch {
|
|
1543
|
-
|
|
1722
|
+
rules.visits.count--;
|
|
1723
|
+
return walk(
|
|
1724
|
+
sanitizeError(error, { ownFields: rules.ownFields }),
|
|
1725
|
+
rules,
|
|
1726
|
+
depth2,
|
|
1727
|
+
ancestors,
|
|
1728
|
+
honorToJson,
|
|
1729
|
+
inSerialized
|
|
1730
|
+
);
|
|
1544
1731
|
}
|
|
1545
1732
|
}
|
|
1546
1733
|
function walkObject(value, rules, depth2, ancestors, honorToJson, inSerialized) {
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
return value;
|
|
1734
|
+
if (ArrayBuffer.isView(value)) {
|
|
1735
|
+
return withBinaryAsSize(value);
|
|
1550
1736
|
}
|
|
1737
|
+
const plain = rules.ownFields.safe;
|
|
1738
|
+
const resolvedToJson = resolveToJson(value, plain);
|
|
1551
1739
|
ancestors.add(value);
|
|
1552
1740
|
try {
|
|
1553
|
-
const
|
|
1741
|
+
const ownsItsForm = rules.ownFields.safe && isError(value);
|
|
1742
|
+
const toJson = honorToJson && !ownsItsForm ? resolvedToJson.method : void 0;
|
|
1554
1743
|
if (toJson !== void 0) {
|
|
1555
1744
|
if (Object.keys(value).some((key) => rules.sensitive.has(key.toLowerCase()))) {
|
|
1556
1745
|
return rules.censor;
|
|
@@ -1558,28 +1747,33 @@ function walkObject(value, rules, depth2, ancestors, honorToJson, inSerialized)
|
|
|
1558
1747
|
return walk(toJson.call(value), rules, depth2 + 1, ancestors, true, inSerialized);
|
|
1559
1748
|
}
|
|
1560
1749
|
if (typeof value === "function") {
|
|
1561
|
-
return value;
|
|
1750
|
+
return plain ? void 0 : value;
|
|
1562
1751
|
}
|
|
1563
1752
|
if (Array.isArray(value)) {
|
|
1564
1753
|
return walkArray(value, rules, depth2, ancestors, inSerialized);
|
|
1565
1754
|
}
|
|
1566
1755
|
const source = value;
|
|
1567
1756
|
const keys = Object.keys(source);
|
|
1568
|
-
const asData = value
|
|
1569
|
-
const clone = value
|
|
1757
|
+
const asData = isError(value) && (plain || rules.errorsAsData && !inSerialized);
|
|
1758
|
+
const clone = isError(value) ? cloneError(value) : void 0;
|
|
1570
1759
|
const copy = clone !== void 0 && !asData ? clone : {};
|
|
1571
|
-
const scrubbed = value
|
|
1760
|
+
const scrubbed = isError(value) && (plain || !inSerialized);
|
|
1761
|
+
const omitted = /* @__PURE__ */ new Set();
|
|
1572
1762
|
for (const key of keys) {
|
|
1573
|
-
const
|
|
1763
|
+
const read = Reflect.get(source, key);
|
|
1764
|
+
const current = scrubbed ? ownFieldForLog(source, key, read, rules.ownFields) : read;
|
|
1574
1765
|
if (current === OMIT_OWN_FIELD) {
|
|
1575
1766
|
Reflect.deleteProperty(copy, key);
|
|
1767
|
+
omitted.add(key);
|
|
1576
1768
|
continue;
|
|
1577
1769
|
}
|
|
1578
1770
|
defineOwn(
|
|
1579
1771
|
copy,
|
|
1580
1772
|
key,
|
|
1581
1773
|
rules.sensitive.has(key.toLowerCase()) ? rules.censor : walk(
|
|
1582
|
-
|
|
1774
|
+
// An own enumerable `name`, `message` or `stack` of an `Error` is the same text as
|
|
1775
|
+
// the part the walk would add, so it is cut the same way.
|
|
1776
|
+
scrubbed && ERROR_TEXT_FIELDS.has(key) ? cutIfText(current) : current,
|
|
1583
1777
|
rules,
|
|
1584
1778
|
depth2 + 1,
|
|
1585
1779
|
ancestors,
|
|
@@ -1588,92 +1782,47 @@ function walkObject(value, rules, depth2, ancestors, honorToJson, inSerialized)
|
|
|
1588
1782
|
)
|
|
1589
1783
|
);
|
|
1590
1784
|
}
|
|
1591
|
-
if (asData)
|
|
1785
|
+
if (asData) {
|
|
1786
|
+
const written = keys.filter((key) => !omitted.has(key));
|
|
1787
|
+
addErrorParts(
|
|
1788
|
+
copy,
|
|
1789
|
+
value,
|
|
1790
|
+
written,
|
|
1791
|
+
errorPartsHost(rules, ancestors, inSerialized),
|
|
1792
|
+
depth2
|
|
1793
|
+
);
|
|
1794
|
+
}
|
|
1592
1795
|
return copy;
|
|
1593
1796
|
} finally {
|
|
1594
1797
|
ancestors.delete(value);
|
|
1595
1798
|
}
|
|
1596
1799
|
}
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
const targets = [];
|
|
1609
|
-
const take = (link) => {
|
|
1610
|
-
if (typeof link === "object" && link !== null) targets.push(link);
|
|
1611
|
-
};
|
|
1612
|
-
if (!Array.isArray(value)) take(value);
|
|
1613
|
-
else for (let index = 0; index < value.length; index++) take(Reflect.get(value, index));
|
|
1614
|
-
return targets;
|
|
1615
|
-
}
|
|
1616
|
-
function walkChainPart(value, level, rules, depth2, ancestors) {
|
|
1617
|
-
const targets = linkTargets(value);
|
|
1618
|
-
if (targets.length > 0 && level + 1 > DEFAULT_MAX_CAUSE_DEPTH) return createDepthMarker();
|
|
1619
|
-
const before = new Map(targets.map((target) => [target, linkDepths.get(target)]));
|
|
1620
|
-
for (const target of targets) linkDepths.set(target, level + 1);
|
|
1621
|
-
try {
|
|
1622
|
-
return walk(value, rules, depth2 + 1, ancestors);
|
|
1623
|
-
} finally {
|
|
1624
|
-
before.forEach((earlier, target) => {
|
|
1625
|
-
if (earlier === void 0) linkDepths.delete(target);
|
|
1626
|
-
else linkDepths.set(target, earlier);
|
|
1627
|
-
});
|
|
1628
|
-
}
|
|
1629
|
-
}
|
|
1630
|
-
function addErrorParts(copy, error, ownKeys, rules, depth2, ancestors) {
|
|
1631
|
-
const taken = new Set(ownKeys);
|
|
1632
|
-
const level = linkDepths.get(error) ?? 0;
|
|
1633
|
-
let incomplete = false;
|
|
1634
|
-
const add = (key, covers, read, write = (value) => walk(value, rules, depth2 + 1, ancestors)) => {
|
|
1635
|
-
if (taken.has(key)) return;
|
|
1636
|
-
try {
|
|
1637
|
-
const written = write(read());
|
|
1638
|
-
if (written === void 0) return;
|
|
1639
|
-
const covered = covers.some((name) => rules.sensitive.has(name));
|
|
1640
|
-
defineOwn(copy, key, covered ? rules.censor : written);
|
|
1641
|
-
} catch {
|
|
1642
|
-
incomplete = true;
|
|
1643
|
-
}
|
|
1800
|
+
function errorPartsHost(rules, ancestors, inSerialized) {
|
|
1801
|
+
return {
|
|
1802
|
+
sensitive: rules.sensitive,
|
|
1803
|
+
censor: rules.censor,
|
|
1804
|
+
// What a serializer receives names the error `name`, as the error-like shape it reads does;
|
|
1805
|
+
// everything else keeps the `type` the written entries use.
|
|
1806
|
+
nameKey: inSerialized ? "name" : "type",
|
|
1807
|
+
walk: (value, depth2) => walk(value, rules, depth2, ancestors, true, inSerialized),
|
|
1808
|
+
// Under 'safe' the cap does not read a list's `toJSON`: a list over the cap becomes a fresh array
|
|
1809
|
+
// and is never read for it, and a list within the cap is read once, by the walk.
|
|
1810
|
+
hasToJson: (value) => !rules.ownFields.safe && resolveToJson(value).method !== void 0
|
|
1644
1811
|
};
|
|
1645
|
-
add("type", ["type", "name"], () => error.name);
|
|
1646
|
-
add("message", ["message"], () => error.message);
|
|
1647
|
-
add(
|
|
1648
|
-
"stack",
|
|
1649
|
-
["stack", "name", "message"],
|
|
1650
|
-
() => error.stack,
|
|
1651
|
-
(stack) => typeof stack === "string" ? scrubStack(stack) : void 0
|
|
1652
|
-
);
|
|
1653
|
-
add(
|
|
1654
|
-
"cause",
|
|
1655
|
-
["cause"],
|
|
1656
|
-
() => error.cause,
|
|
1657
|
-
(cause) => walkChainPart(cause, level, rules, depth2, ancestors)
|
|
1658
|
-
);
|
|
1659
|
-
add(
|
|
1660
|
-
"errors",
|
|
1661
|
-
["errors"],
|
|
1662
|
-
() => capErrors(error.errors),
|
|
1663
|
-
(errors) => walkChainPart(errors, level, rules, depth2, ancestors)
|
|
1664
|
-
);
|
|
1665
|
-
if (incomplete && !taken.has(INCOMPLETE_KEY)) defineOwn(copy, INCOMPLETE_KEY, true);
|
|
1666
1812
|
}
|
|
1667
|
-
function createNameRedactor(fieldNames, censor, serializedKeys) {
|
|
1813
|
+
function createNameRedactor(fieldNames, censor, serializedKeys, maxVisits = REDACT_MAX_VISITS, ownFields = ALL_OWN_FIELDS) {
|
|
1668
1814
|
const rules = {
|
|
1669
|
-
sensitive: new Set(
|
|
1815
|
+
sensitive: new Set(Array.from(fieldNames, (name) => name.toLowerCase())),
|
|
1670
1816
|
censor,
|
|
1671
1817
|
serializedKeys: new Set(serializedKeys),
|
|
1672
|
-
errorsAsData: serializedKeys !== void 0
|
|
1818
|
+
errorsAsData: serializedKeys !== void 0,
|
|
1819
|
+
maxVisits,
|
|
1820
|
+
ownFields
|
|
1673
1821
|
};
|
|
1674
1822
|
return (value, isRecordRoot = false) => {
|
|
1675
1823
|
try {
|
|
1676
|
-
|
|
1824
|
+
const call = { ...rules, visits: { count: 0 } };
|
|
1825
|
+
return walk(value, call, 0, /* @__PURE__ */ new Set(), !isRecordRoot);
|
|
1677
1826
|
} catch {
|
|
1678
1827
|
return {
|
|
1679
1828
|
_redactionFailed: true,
|
|
@@ -1845,8 +1994,8 @@ function leafNameOf(path2) {
|
|
|
1845
1994
|
}
|
|
1846
1995
|
return leaf;
|
|
1847
1996
|
}
|
|
1848
|
-
function serializeErrorValue(value_) {
|
|
1849
|
-
const sanitized = sanitizeError(value_);
|
|
1997
|
+
function serializeErrorValue(value_, ownFields = ALL_OWN_FIELDS) {
|
|
1998
|
+
const sanitized = sanitizeError(value_, { ownFields });
|
|
1850
1999
|
const serialized = {
|
|
1851
2000
|
// `type` rather than `name`: the field consumers already query.
|
|
1852
2001
|
type: sanitized.name,
|
|
@@ -1871,11 +2020,11 @@ function withSemconvException(record, format) {
|
|
|
1871
2020
|
try {
|
|
1872
2021
|
const candidate = record["err"];
|
|
1873
2022
|
if (typeof candidate?.name === "string") {
|
|
1874
|
-
record["exception.type"] = candidate.name;
|
|
1875
|
-
record["error.type"] = candidate.name;
|
|
2023
|
+
record["exception.type"] = cutText(candidate.name);
|
|
2024
|
+
record["error.type"] = cutText(candidate.name);
|
|
1876
2025
|
}
|
|
1877
2026
|
if (typeof candidate?.message === "string") {
|
|
1878
|
-
record["exception.message"] = candidate.message;
|
|
2027
|
+
record["exception.message"] = cutText(candidate.message);
|
|
1879
2028
|
}
|
|
1880
2029
|
if (typeof candidate?.stack === "string") {
|
|
1881
2030
|
record["exception.stacktrace"] = scrubStack(candidate.stack);
|
|
@@ -1908,20 +2057,28 @@ function withEventName(record, field) {
|
|
|
1908
2057
|
}
|
|
1909
2058
|
var PASS_THROUGH = (value) => value;
|
|
1910
2059
|
function resolveNameRedactor(options) {
|
|
1911
|
-
|
|
1912
|
-
return PASS_THROUGH;
|
|
1913
|
-
}
|
|
1914
|
-
return buildNameRedactor(options, true);
|
|
2060
|
+
return buildNameRedactor(options, true, options.redactStrategy === "names");
|
|
1915
2061
|
}
|
|
1916
|
-
function
|
|
1917
|
-
|
|
2062
|
+
function ownFieldPolicyOf(options) {
|
|
2063
|
+
return createOwnFieldPolicy(options.errorOwnFields, options.errorOwnFieldNames);
|
|
2064
|
+
}
|
|
2065
|
+
function buildNameRedactor(options, nestedErrorsAsData = false, coversNames = true) {
|
|
2066
|
+
const names = coversNames ? [
|
|
1918
2067
|
...options.shouldDisableDefaultRedact ? [] : REDACT_COMMON_FIELDS,
|
|
1919
2068
|
...options.redactPaths.flatMap((path2) => leafNameOf(path2) ?? [])
|
|
1920
|
-
];
|
|
1921
|
-
|
|
2069
|
+
] : [];
|
|
2070
|
+
const ownFields = ownFieldPolicyOf(options);
|
|
2071
|
+
const walks = names.length > 0 || ownFields.safe;
|
|
2072
|
+
if (!walks && resolveRedactOption(options) === void 0) {
|
|
1922
2073
|
return PASS_THROUGH;
|
|
1923
2074
|
}
|
|
1924
|
-
return nestedErrorsAsData
|
|
2075
|
+
return nestedErrorsAsData && walks ? createNameRedactor(
|
|
2076
|
+
names,
|
|
2077
|
+
options.redactCensor,
|
|
2078
|
+
["err", ...Object.keys(options.serializers)],
|
|
2079
|
+
void 0,
|
|
2080
|
+
ownFields
|
|
2081
|
+
) : createNameRedactor(names, options.redactCensor, void 0, void 0, ownFields);
|
|
1925
2082
|
}
|
|
1926
2083
|
function resolveRedactOption(options) {
|
|
1927
2084
|
const paths = options.redactStrategy === "paths" ? compileRedactPaths(options.redactPaths, options.shouldDisableDefaultRedact) : [...new Set(options.redactPaths)];
|
|
@@ -1934,9 +2091,10 @@ function buildPinoInstance(options, logContext, destinations, health) {
|
|
|
1934
2091
|
const maxBytes = options.maxEntrySizeBytes;
|
|
1935
2092
|
const redactRecord = resolveNameRedactor(options);
|
|
1936
2093
|
const redactSerialized = buildNameRedactor(options);
|
|
2094
|
+
const ownFields = ownFieldPolicyOf(options);
|
|
1937
2095
|
const bound = (serializer) => createSizeBoundedSerializer((input) => redactSerialized(serializer(input)), maxBytes);
|
|
1938
2096
|
const serializers = {
|
|
1939
|
-
err: bound(serializeErrorValue),
|
|
2097
|
+
err: bound((error) => serializeErrorValue(error, ownFields)),
|
|
1940
2098
|
...Object.fromEntries(
|
|
1941
2099
|
Object.entries(options.serializers).map(
|
|
1942
2100
|
([key, serializer]) => [key, bound(serializer)]
|
|
@@ -2437,7 +2595,7 @@ var DestinationRegistry = class {
|
|
|
2437
2595
|
let detail = "UnknownError";
|
|
2438
2596
|
try {
|
|
2439
2597
|
const stack = isErrorLike(cause) ? cause.stack : void 0;
|
|
2440
|
-
detail = stack === void 0 ?
|
|
2598
|
+
detail = stack === void 0 ? toBoundedMessage(isErrorLike(cause) ? String(cause.message) : String(cause)) : escapeControlCharacters(cutText(String(stack)));
|
|
2441
2599
|
} catch {
|
|
2442
2600
|
}
|
|
2443
2601
|
writeStderrSafely(`[DestinationRegistry] Shutdown failed for "${name}": ${detail}
|
|
@@ -2780,7 +2938,7 @@ function isPinoPrettyMissing(cause) {
|
|
|
2780
2938
|
}
|
|
2781
2939
|
function describeFailure(cause) {
|
|
2782
2940
|
try {
|
|
2783
|
-
return
|
|
2941
|
+
return toBoundedMessage(isError(cause) ? cause.message : String(cause));
|
|
2784
2942
|
} catch {
|
|
2785
2943
|
return "unreadable value";
|
|
2786
2944
|
}
|
|
@@ -3084,7 +3242,7 @@ var HttpAccessLogMiddleware = class {
|
|
|
3084
3242
|
RESERVED_LOG_KEYS.HTTP_REQUEST_CLIENT_ERROR,
|
|
3085
3243
|
`${method} ${url} \u2192 ${statusCode}`,
|
|
3086
3244
|
userId,
|
|
3087
|
-
recorded === void 0 ? meta : { ...meta, errorMessage: recorded.error.message }
|
|
3245
|
+
recorded === void 0 ? meta : { ...meta, errorMessage: cutIfText(recorded.error.message) }
|
|
3088
3246
|
);
|
|
3089
3247
|
return;
|
|
3090
3248
|
}
|