@bymax-one/nest-logger 1.4.13 → 1.4.14

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.
@@ -31,7 +31,8 @@ var DEFAULT_HTTP = {
31
31
  shouldCaptureExceptions: true,
32
32
  shouldGenerateRequestId: true,
33
33
  excludePaths: [/^\/health$/, /^\/health\/live$/, /^\/health\/ready$/, /^\/metrics$/],
34
- tenantIdHeader: "x-tenant-id"
34
+ tenantIdHeader: "x-tenant-id",
35
+ tenantIdResolver: void 0
35
36
  };
36
37
  var DEFAULT_OTEL = {
37
38
  shouldAutoInjectTraceContext: true,
@@ -296,7 +297,14 @@ function validateHttp(options) {
296
297
  }
297
298
  });
298
299
  }
299
- checkNonEmptyString("http.tenantIdHeader", http["tenantIdHeader"]);
300
+ const tenantIdHeader = http["tenantIdHeader"];
301
+ if (tenantIdHeader !== void 0 && tenantIdHeader !== false && !isNonEmptyString(tenantIdHeader)) {
302
+ reject("http.tenantIdHeader", "must be a non-empty string or false", tenantIdHeader);
303
+ }
304
+ const tenantIdResolver = http["tenantIdResolver"];
305
+ if (tenantIdResolver !== void 0 && typeof tenantIdResolver !== "function") {
306
+ reject("http.tenantIdResolver", "must be a function", tenantIdResolver);
307
+ }
300
308
  }
301
309
  function validateOtel(options) {
302
310
  const otel = checkGroup("otel", options.otel);
@@ -968,6 +976,15 @@ exports.DefaultStdoutDestination = __decorateClass([
968
976
  // src/server/utils/exposed-client-error.util.ts
969
977
  var MIN_CLIENT_STATUS = 400;
970
978
  var MAX_CLIENT_STATUS = 499;
979
+ var FIXED_MESSAGES = /* @__PURE__ */ new Map([
980
+ ["encoding.unsupported", "unsupported content encoding"],
981
+ ["charset.unsupported", "unsupported charset"]
982
+ ]);
983
+ var FIXED_LOG_MESSAGES = new Map([
984
+ ...FIXED_MESSAGES,
985
+ ["entity.parse.failed", "request body could not be parsed"],
986
+ ["entity.verify.failed", "request body verification failed"]
987
+ ]);
971
988
  function readExposedClientError(value) {
972
989
  try {
973
990
  const candidate = value;
@@ -976,12 +993,66 @@ function readExposedClientError(value) {
976
993
  const isClientStatus = typeof status === "number" && Number.isInteger(status) && status >= MIN_CLIENT_STATUS && status <= MAX_CLIENT_STATUS;
977
994
  if (candidate.expose !== true || !isClientStatus || typeof message !== "string")
978
995
  return void 0;
979
- return { status, message };
996
+ const type = candidate.type;
997
+ const sent = FIXED_MESSAGES.get(type) ?? message;
998
+ const logged = FIXED_LOG_MESSAGES.get(type);
999
+ return logged === void 0 ? { status, message: sent, logMessage: sent } : { status, message: sent, logMessage: logged, bodyParserType: type };
980
1000
  } catch {
981
1001
  return void 0;
982
1002
  }
983
1003
  }
984
1004
 
1005
+ // src/server/utils/http-log-state.util.ts
1006
+ var HTTP_REDIRECT_MIN = 300;
1007
+ var HTTP_CLIENT_ERROR_MIN = 400;
1008
+ var HTTP_SERVER_ERROR_MIN = 500;
1009
+ var UNKNOWN_USER_AGENT = "unknown";
1010
+ var RECORDER_ACTIVE = /* @__PURE__ */ Symbol("bymax-one/nest-logger:recorder");
1011
+ var RECORDED_ERROR = /* @__PURE__ */ Symbol("bymax-one/nest-logger:error");
1012
+ var PARSER_ERROR = /* @__PURE__ */ Symbol("bymax-one/nest-logger:parser-error");
1013
+ var OWN_REQUEST_ID = /* @__PURE__ */ Symbol("bymax-one/nest-logger:request-id");
1014
+ var CORRELATION_OPENED = /* @__PURE__ */ Symbol("bymax-one/nest-logger:correlation");
1015
+ function markRecorderActive(req) {
1016
+ Reflect.set(req, RECORDER_ACTIVE, true);
1017
+ }
1018
+ function isRecorderActive(req) {
1019
+ return Reflect.get(req, RECORDER_ACTIVE) === true;
1020
+ }
1021
+ function markCorrelationOpened(req) {
1022
+ Reflect.set(req, CORRELATION_OPENED, true);
1023
+ }
1024
+ function isCorrelationOpened(req) {
1025
+ return Reflect.get(req, CORRELATION_OPENED) === true;
1026
+ }
1027
+ function markOwnRequestId(req, requestId) {
1028
+ Reflect.set(req, OWN_REQUEST_ID, requestId);
1029
+ }
1030
+ function readOwnRequestId(req) {
1031
+ return Reflect.get(req, OWN_REQUEST_ID);
1032
+ }
1033
+ function recordError(req, error) {
1034
+ Reflect.set(req, RECORDED_ERROR, { error });
1035
+ }
1036
+ function readRecordedError(req) {
1037
+ return Reflect.get(req, RECORDED_ERROR);
1038
+ }
1039
+ function recordParserError(req, error) {
1040
+ Reflect.set(req, PARSER_ERROR, error);
1041
+ }
1042
+ function readRecordedParserError(req) {
1043
+ return Reflect.get(req, PARSER_ERROR);
1044
+ }
1045
+ function toError(thrown) {
1046
+ return isError(thrown) ? thrown : new Error(String(thrown));
1047
+ }
1048
+ function readUserId(req) {
1049
+ return req.user?.sub ?? req.user?.id;
1050
+ }
1051
+ function readUserAgent(req) {
1052
+ const raw = req.headers["user-agent"];
1053
+ return typeof raw === "string" ? raw : UNKNOWN_USER_AGENT;
1054
+ }
1055
+
985
1056
  // src/server/utils/normalize-url.util.ts
986
1057
  var UUID_REGEX = /\/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}(?![0-9a-f])/gi;
987
1058
  var ULID_REGEX = /\/[0-9A-HJKMNP-TV-Z]{26}(?![0-9A-HJKMNP-TV-Z])/g;
@@ -995,6 +1066,20 @@ function stripQueryString(url) {
995
1066
  const queryStart = url.indexOf("?");
996
1067
  return queryStart === -1 ? url : url.slice(0, queryStart);
997
1068
  }
1069
+ function withoutRequestQuery(text, ...urls) {
1070
+ let result = text;
1071
+ for (const url of urls) {
1072
+ if (url === void 0) continue;
1073
+ const queryStart = url.indexOf("?");
1074
+ if (queryStart !== -1 && url.length - queryStart > 1) {
1075
+ result = result.split(url.slice(queryStart)).join("");
1076
+ }
1077
+ }
1078
+ return result;
1079
+ }
1080
+ function withoutRequestQueryIfText(value, ...urls) {
1081
+ return typeof value === "string" ? withoutRequestQuery(value, ...urls) : value;
1082
+ }
998
1083
 
999
1084
  // src/server/filters/http-exception.filter.ts
1000
1085
  var INTERNAL_ERROR_BODY = {
@@ -1025,7 +1110,13 @@ exports.HttpExceptionFilter = class HttpExceptionFilter {
1025
1110
  const url = stripQueryString(req.url);
1026
1111
  if (exception instanceof common.HttpException) {
1027
1112
  const status = exception.getStatus();
1028
- const metadata = { method: req.method, url, status };
1113
+ const parserError = readRecordedParserError(req);
1114
+ const metadata = {
1115
+ method: req.method,
1116
+ url,
1117
+ status,
1118
+ bodyParserType: parserError?.bodyParserType
1119
+ };
1029
1120
  if (status >= common.HttpStatus.INTERNAL_SERVER_ERROR) {
1030
1121
  this.logger.errorStructured(
1031
1122
  RESERVED_LOG_KEYS.HTTP_EXCEPTION_UNHANDLED,
@@ -1036,7 +1127,7 @@ exports.HttpExceptionFilter = class HttpExceptionFilter {
1036
1127
  } else {
1037
1128
  this.logger.warnStructured(
1038
1129
  RESERVED_LOG_KEYS.HTTP_EXCEPTION_HANDLED,
1039
- exception.message,
1130
+ parserError?.logMessage ?? withoutRequestQuery(exception.message, req.originalUrl, req.url),
1040
1131
  userId,
1041
1132
  metadata
1042
1133
  );
@@ -1046,7 +1137,10 @@ exports.HttpExceptionFilter = class HttpExceptionFilter {
1046
1137
  }
1047
1138
  const clientError = readExposedClientError(exception);
1048
1139
  if (clientError !== void 0) {
1049
- this.answerClientError(clientError, res, { method: req.method, url, userId });
1140
+ this.answerClientError(clientError, res, { method: req.method, url, userId }, [
1141
+ req.originalUrl,
1142
+ req.url
1143
+ ]);
1050
1144
  return;
1051
1145
  }
1052
1146
  this.answerUnhandled(exception, res, { method: req.method, url, userId });
@@ -1057,14 +1151,20 @@ exports.HttpExceptionFilter = class HttpExceptionFilter {
1057
1151
  * @param clientError - The status and message the error exposes.
1058
1152
  * @param res - The response to write.
1059
1153
  * @param request - The request facts every entry carries.
1154
+ * @param rawUrls - The request's own URLs, whose query string a logged message must not carry.
1060
1155
  */
1061
- answerClientError(clientError, res, request) {
1156
+ answerClientError(clientError, res, request, rawUrls) {
1062
1157
  const { method, url, userId } = request;
1063
1158
  this.logger.warnStructured(
1064
1159
  RESERVED_LOG_KEYS.HTTP_EXCEPTION_HANDLED,
1065
- clientError.message,
1160
+ withoutRequestQuery(clientError.logMessage, ...rawUrls),
1066
1161
  userId,
1067
- { method, url, status: clientError.status }
1162
+ {
1163
+ method,
1164
+ url,
1165
+ status: clientError.status,
1166
+ bodyParserType: clientError.bodyParserType
1167
+ }
1068
1168
  );
1069
1169
  res.status(clientError.status).json({
1070
1170
  statusCode: clientError.status,
@@ -1095,50 +1195,6 @@ exports.HttpExceptionFilter = __decorateClass([
1095
1195
  __decorateParam(0, common.Inject(exports.PinoLoggerService))
1096
1196
  ], exports.HttpExceptionFilter);
1097
1197
 
1098
- // src/server/utils/http-log-state.util.ts
1099
- var HTTP_REDIRECT_MIN = 300;
1100
- var HTTP_CLIENT_ERROR_MIN = 400;
1101
- var HTTP_SERVER_ERROR_MIN = 500;
1102
- var UNKNOWN_USER_AGENT = "unknown";
1103
- var RECORDER_ACTIVE = /* @__PURE__ */ Symbol("bymax-one/nest-logger:recorder");
1104
- var RECORDED_ERROR = /* @__PURE__ */ Symbol("bymax-one/nest-logger:error");
1105
- var OWN_REQUEST_ID = /* @__PURE__ */ Symbol("bymax-one/nest-logger:request-id");
1106
- var CORRELATION_OPENED = /* @__PURE__ */ Symbol("bymax-one/nest-logger:correlation");
1107
- function markRecorderActive(req) {
1108
- Reflect.set(req, RECORDER_ACTIVE, true);
1109
- }
1110
- function isRecorderActive(req) {
1111
- return Reflect.get(req, RECORDER_ACTIVE) === true;
1112
- }
1113
- function markCorrelationOpened(req) {
1114
- Reflect.set(req, CORRELATION_OPENED, true);
1115
- }
1116
- function isCorrelationOpened(req) {
1117
- return Reflect.get(req, CORRELATION_OPENED) === true;
1118
- }
1119
- function markOwnRequestId(req, requestId) {
1120
- Reflect.set(req, OWN_REQUEST_ID, requestId);
1121
- }
1122
- function readOwnRequestId(req) {
1123
- return Reflect.get(req, OWN_REQUEST_ID);
1124
- }
1125
- function recordError(req, error) {
1126
- Reflect.set(req, RECORDED_ERROR, { error });
1127
- }
1128
- function readRecordedError(req) {
1129
- return Reflect.get(req, RECORDED_ERROR);
1130
- }
1131
- function toError(thrown) {
1132
- return isError(thrown) ? thrown : new Error(String(thrown));
1133
- }
1134
- function readUserId(req) {
1135
- return req.user?.sub ?? req.user?.id;
1136
- }
1137
- function readUserAgent(req) {
1138
- const raw = req.headers["user-agent"];
1139
- return typeof raw === "string" ? raw : UNKNOWN_USER_AGENT;
1140
- }
1141
-
1142
1198
  // src/server/utils/matches-exclude-path.util.ts
1143
1199
  function matchesExcludePath(patterns, path) {
1144
1200
  return patterns.some((pattern) => {
@@ -1210,7 +1266,10 @@ exports.HttpLoggingInterceptor = class HttpLoggingInterceptor {
1210
1266
  this.logSuccess(res.statusCode, method, normalizedUrl, userId, Date.now() - start);
1211
1267
  }),
1212
1268
  rxjs.catchError((err) => {
1213
- this.logError(err, method, normalizedUrl, userId, Date.now() - start);
1269
+ this.logError(err, method, normalizedUrl, userId, Date.now() - start, [
1270
+ req.originalUrl,
1271
+ url
1272
+ ]);
1214
1273
  return rxjs.throwError(() => err);
1215
1274
  })
1216
1275
  );
@@ -1274,8 +1333,9 @@ exports.HttpLoggingInterceptor = class HttpLoggingInterceptor {
1274
1333
  * @param url - The normalized request URL.
1275
1334
  * @param userId - The acting user id, when known.
1276
1335
  * @param duration - The elapsed time in milliseconds.
1336
+ * @param rawUrls - The request's own URLs, whose query string a logged message must not carry.
1277
1337
  */
1278
- logError(err, method, url, userId, duration) {
1338
+ logError(err, method, url, userId, duration, rawUrls) {
1279
1339
  if (err instanceof common.HttpException) {
1280
1340
  const statusCode = err.getStatus();
1281
1341
  if (statusCode >= HTTP_SERVER_ERROR_MIN) {
@@ -1290,14 +1350,20 @@ exports.HttpLoggingInterceptor = class HttpLoggingInterceptor {
1290
1350
  RESERVED_LOG_KEYS.HTTP_REQUEST_CLIENT_ERROR,
1291
1351
  `${method} ${url} \u2192 ${statusCode}`,
1292
1352
  userId,
1293
- { method, url, statusCode, duration, errorMessage: cutIfText(err.message) }
1353
+ {
1354
+ method,
1355
+ url,
1356
+ statusCode,
1357
+ duration,
1358
+ errorMessage: cutIfText(withoutRequestQueryIfText(err.message, ...rawUrls))
1359
+ }
1294
1360
  );
1295
1361
  }
1296
1362
  return;
1297
1363
  }
1298
1364
  const clientError = readExposedClientError(err);
1299
1365
  if (clientError !== void 0) {
1300
- this.logClientError(clientError, method, url, userId, duration);
1366
+ this.logClientError(clientError, method, url, userId, duration, rawUrls);
1301
1367
  return;
1302
1368
  }
1303
1369
  this.logger.errorStructured(RESERVED_LOG_KEYS.HTTP_REQUEST_SERVER_ERROR, toError(err), userId, {
@@ -1315,8 +1381,9 @@ exports.HttpLoggingInterceptor = class HttpLoggingInterceptor {
1315
1381
  * @param url - The normalized request URL.
1316
1382
  * @param userId - The acting user id, when known.
1317
1383
  * @param duration - The elapsed time in milliseconds.
1384
+ * @param rawUrls - The request's own URLs, whose query string a logged message must not carry.
1318
1385
  */
1319
- logClientError(clientError, method, url, userId, duration) {
1386
+ logClientError(clientError, method, url, userId, duration, rawUrls) {
1320
1387
  this.logger.warnStructured(
1321
1388
  RESERVED_LOG_KEYS.HTTP_REQUEST_CLIENT_ERROR,
1322
1389
  `${method} ${url} \u2192 ${clientError.status}`,
@@ -1326,7 +1393,8 @@ exports.HttpLoggingInterceptor = class HttpLoggingInterceptor {
1326
1393
  url,
1327
1394
  statusCode: clientError.status,
1328
1395
  duration,
1329
- errorMessage: cutIfText(clientError.message)
1396
+ errorMessage: cutIfText(withoutRequestQueryIfText(clientError.logMessage, ...rawUrls)),
1397
+ bodyParserType: clientError.bodyParserType
1330
1398
  }
1331
1399
  );
1332
1400
  }
@@ -1494,6 +1562,9 @@ exports.LogContextService = __decorateClass([
1494
1562
  var REQUEST_ID_HEADER = "x-request-id";
1495
1563
  var MAX_CORRELATION_ID_LENGTH = 256;
1496
1564
  var CORRELATION_ID_CHARSET = /^[A-Za-z0-9._:/+=-]+$/;
1565
+ function settleLate(answer) {
1566
+ Promise.resolve(answer).catch(() => void 0);
1567
+ }
1497
1568
  var INHERITABLE_CONTEXT_KEYS = ["requestId", "tenantId"];
1498
1569
  function isAcceptableHeaderValue(value) {
1499
1570
  return typeof value === "string" && value.length <= MAX_CORRELATION_ID_LENGTH && CORRELATION_ID_CHARSET.test(value);
@@ -1509,6 +1580,7 @@ exports.RequestIdMiddleware = class RequestIdMiddleware {
1509
1580
  constructor(logContext, options) {
1510
1581
  this.logContext = logContext;
1511
1582
  this.tenantIdHeader = options.http.tenantIdHeader;
1583
+ this.tenantIdResolver = options.http.tenantIdResolver;
1512
1584
  this.shouldGenerateRequestId = options.http.shouldGenerateRequestId;
1513
1585
  }
1514
1586
  /**
@@ -1623,18 +1695,36 @@ exports.RequestIdMiddleware = class RequestIdMiddleware {
1623
1695
  return fromHeader ?? (this.shouldGenerateRequestId ? crypto.randomUUID() : void 0);
1624
1696
  }
1625
1697
  /**
1626
- * The tenant id carried by the configured header, when it is acceptable.
1698
+ * The tenant id of the request, when it is acceptable.
1627
1699
  *
1628
- * Never minted: a tenant is an assertion about who the request belongs to, and
1629
- * inventing one would be a fabricated claim rather than a correlation aid.
1700
+ * From the host's resolver when it gave one, else from the configured header, else none. Never
1701
+ * minted: a tenant is an assertion about who the request belongs to, and inventing one would be a
1702
+ * fabricated claim rather than a correlation aid.
1630
1703
  *
1631
1704
  * @param req - The incoming request.
1632
1705
  * @returns The tenant id, or `undefined`.
1633
1706
  */
1634
1707
  resolveTenantId(req) {
1708
+ if (this.tenantIdResolver !== void 0)
1709
+ return this.resolvedTenantId(this.tenantIdResolver, req);
1710
+ if (this.tenantIdHeader === false) return void 0;
1635
1711
  const raw = Reflect.get(req.headers, this.tenantIdHeader);
1636
1712
  return isAcceptableHeaderValue(raw) ? raw : void 0;
1637
1713
  }
1714
+ /**
1715
+ * The answer of the host's resolver, when it is acceptable. A resolver that throws gives none: a
1716
+ * log context never costs the request.
1717
+ */
1718
+ resolvedTenantId(resolver, req) {
1719
+ try {
1720
+ const answer = resolver(req);
1721
+ if (isAcceptableHeaderValue(answer)) return answer;
1722
+ settleLate(answer);
1723
+ return void 0;
1724
+ } catch {
1725
+ return void 0;
1726
+ }
1727
+ }
1638
1728
  };
1639
1729
  exports.RequestIdMiddleware = __decorateClass([
1640
1730
  common.Injectable(),
@@ -1661,6 +1751,16 @@ function applyRequestContext(app) {
1661
1751
  });
1662
1752
  }
1663
1753
 
1754
+ // src/server/middlewares/record-parser-error.middleware.ts
1755
+ function recordParserErrorMiddleware(error, req, _res, next) {
1756
+ try {
1757
+ const exposed = readExposedClientError(error);
1758
+ if (exposed?.bodyParserType !== void 0) recordParserError(req, exposed);
1759
+ } catch {
1760
+ }
1761
+ next(error);
1762
+ }
1763
+
1664
1764
  // src/server/constants/default-redact-paths.constants.ts
1665
1765
  var REDACT_MAX_DEPTH = 4;
1666
1766
  var WILDCARD_PREFIXES = Array.from(
@@ -1940,7 +2040,7 @@ function destinationToStream(destination, health) {
1940
2040
 
1941
2041
  // src/server/utils/redact-error-parts.util.ts
1942
2042
  function defineOwn(target, key, value) {
1943
- Reflect.defineProperty(target, key, { value, enumerable: true });
2043
+ Reflect.defineProperty(target, key, { value, enumerable: true, writable: true });
1944
2044
  }
1945
2045
  var linkDepths = /* @__PURE__ */ new WeakMap();
1946
2046
  var ERROR_TEXT_FIELDS = /* @__PURE__ */ new Set(["name", "message", "stack"]);
@@ -2036,27 +2136,46 @@ var REDACT_BUDGET_EXCEEDED = "[REDACTION_BUDGET_EXCEEDED]";
2036
2136
  var REDACT_CIRCULAR = "[Circular]";
2037
2137
  function resolveToJson(value, viaGet = false) {
2038
2138
  let candidate = viaGet ? Reflect.get(value, "toJSON") : void 0;
2139
+ let accessor = false;
2140
+ let proxied = false;
2039
2141
  let current = viaGet ? null : value;
2040
2142
  while (current !== null) {
2143
+ proxied = proxied || util.types.isProxy(current);
2041
2144
  const descriptor = Object.getOwnPropertyDescriptor(current, "toJSON");
2042
2145
  if (descriptor !== void 0) {
2146
+ accessor = descriptor.get !== void 0;
2043
2147
  candidate = descriptor.get === void 0 ? descriptor.value : descriptor.get.call(value);
2044
2148
  break;
2045
2149
  }
2046
2150
  current = Object.getPrototypeOf(current);
2047
2151
  }
2048
- return { method: typeof candidate === "function" ? candidate : void 0 };
2152
+ return {
2153
+ method: typeof candidate === "function" ? candidate : void 0,
2154
+ volatile: accessor || proxied
2155
+ };
2156
+ }
2157
+ function shadowHook(target) {
2158
+ Reflect.defineProperty(target, "toJSON", { value: void 0, configurable: true });
2159
+ }
2160
+ function withoutEnumerableKeys(clone) {
2161
+ for (const key of Object.keys(clone)) Reflect.deleteProperty(clone, key);
2162
+ }
2163
+ function discardWrite() {
2049
2164
  }
2050
2165
  function cloneError(error) {
2051
2166
  const descriptors = Object.getOwnPropertyDescriptors(error);
2052
2167
  for (const descriptor of Object.values(descriptors)) {
2053
2168
  descriptor.configurable = true;
2169
+ if ("value" in descriptor) descriptor.writable = true;
2170
+ else descriptor.set ??= discardWrite;
2054
2171
  }
2055
2172
  const clone = Object.create(Object.getPrototypeOf(error), descriptors);
2056
2173
  const { stack } = error;
2057
2174
  if (typeof stack === "string") {
2058
- Reflect.defineProperty(clone, "stack", { value: stack, enumerable: false });
2175
+ Reflect.defineProperty(clone, "stack", { value: stack, enumerable: false, writable: true });
2059
2176
  }
2177
+ withoutEnumerableKeys(clone);
2178
+ shadowHook(clone);
2060
2179
  return clone;
2061
2180
  }
2062
2181
  function walkArray(value, rules, depth2, ancestors, inSerialized) {
@@ -2111,22 +2230,22 @@ function walkObject(value, rules, depth2, ancestors, honorToJson, inSerialized)
2111
2230
  if (ArrayBuffer.isView(value)) {
2112
2231
  return withBinaryAsSize(value);
2113
2232
  }
2114
- const method = resolveToJson(value, rules.ownFields.safe).method;
2233
+ const resolved = resolveToJson(value, rules.ownFields.safe);
2115
2234
  ancestors.add(value);
2116
2235
  try {
2117
- return walkForm(value, method, rules, depth2, ancestors, honorToJson, inSerialized);
2236
+ return walkForm(value, resolved, rules, depth2, ancestors, honorToJson, inSerialized);
2118
2237
  } finally {
2119
2238
  ancestors.delete(value);
2120
2239
  }
2121
2240
  }
2122
- function walkForm(value, method, rules, depth2, ancestors, honorToJson, inSerialized) {
2241
+ function walkForm(value, resolved, rules, depth2, ancestors, honorToJson, inSerialized) {
2123
2242
  const plain = rules.ownFields.safe;
2124
- const toJson = honorToJson && !(plain && isError(value)) ? method : void 0;
2243
+ const toJson = honorToJson && !(plain && isError(value)) ? resolved.method : void 0;
2125
2244
  if (toJson !== void 0) {
2126
2245
  return walkToJsonOutput(value, toJson, rules, depth2, ancestors, inSerialized);
2127
2246
  }
2128
2247
  if (typeof value === "function") {
2129
- return plain ? void 0 : value;
2248
+ return plain || resolved.volatile ? void 0 : value;
2130
2249
  }
2131
2250
  if (Array.isArray(value)) {
2132
2251
  return walkArray(value, rules, depth2, ancestors, inSerialized);
@@ -2150,11 +2269,12 @@ function walkProperties(value, rules, depth2, ancestors, honorToJson, inSerializ
2150
2269
  for (const key of keys) {
2151
2270
  const read = Reflect.get(source, key);
2152
2271
  const current = scrubbed ? ownFieldForLog(source, key, read, rules.ownFields) : read;
2153
- if (current === OMIT_OWN_FIELD) {
2154
- Reflect.deleteProperty(copy, key);
2272
+ const hook = honorToJson && key === "toJSON" && typeof current === "function";
2273
+ if (current === OMIT_OWN_FIELD || hook) {
2155
2274
  omitted.add(key);
2156
2275
  continue;
2157
2276
  }
2277
+ Reflect.deleteProperty(copy, key);
2158
2278
  defineOwn(
2159
2279
  copy,
2160
2280
  key,
@@ -3073,6 +3193,26 @@ function augmentLoggerModule(base, providers) {
3073
3193
  };
3074
3194
  }
3075
3195
  exports.BymaxLoggerModule = class BymaxLoggerModule extends BymaxLoggerModuleBase {
3196
+ /**
3197
+ * @param httpAdapterHost - The HTTP adapter, absent in an application with no HTTP server.
3198
+ */
3199
+ constructor(httpAdapterHost) {
3200
+ super();
3201
+ this.httpAdapterHost = httpAdapterHost;
3202
+ }
3203
+ /**
3204
+ * Mount the error layer that keeps the type of a body-parser error for the exception filter.
3205
+ * It runs after the body parser, which Nest registers first, and before Nest's exception
3206
+ * handler, and it passes every error on. Only the Express adapter has such a layer.
3207
+ *
3208
+ * @param _consumer - The middleware consumer, unused: an error layer is not consumer middleware.
3209
+ */
3210
+ configure(_consumer) {
3211
+ const adapter = this.httpAdapterHost.httpAdapter;
3212
+ if (adapter?.getType() === "express") {
3213
+ adapter.getInstance().use(recordParserErrorMiddleware);
3214
+ }
3215
+ }
3076
3216
  /**
3077
3217
  * Synchronous registration.
3078
3218
  *
@@ -3190,7 +3330,8 @@ exports.BymaxLoggerModule = class BymaxLoggerModule extends BymaxLoggerModuleBas
3190
3330
  }
3191
3331
  };
3192
3332
  exports.BymaxLoggerModule = __decorateClass([
3193
- common.Module({})
3333
+ common.Module({}),
3334
+ __decorateParam(0, common.Inject(core.HttpAdapterHost))
3194
3335
  ], exports.BymaxLoggerModule);
3195
3336
 
3196
3337
  // src/server/destinations/pretty-dev.destination.ts
@@ -3520,7 +3661,12 @@ exports.HttpAccessLogMiddleware = class HttpAccessLogMiddleware {
3520
3661
  RESERVED_LOG_KEYS.HTTP_REQUEST_CLIENT_ERROR,
3521
3662
  `${method} ${url} \u2192 ${statusCode}`,
3522
3663
  userId,
3523
- recorded === void 0 ? meta : { ...meta, errorMessage: cutIfText(recorded.error.message) }
3664
+ recorded === void 0 ? meta : {
3665
+ ...meta,
3666
+ errorMessage: cutIfText(
3667
+ withoutRequestQueryIfText(recorded.error.message, req.originalUrl, req.url)
3668
+ )
3669
+ }
3524
3670
  );
3525
3671
  return;
3526
3672
  }