lhisp-logger 3.1.5 → 3.1.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lhisp-logger",
3
- "version": "3.1.5",
3
+ "version": "3.1.6",
4
4
  "description": "",
5
5
  "main": "src/lhisp-logger",
6
6
  "types": "src/lhisp-logger.d.ts",
@@ -4,7 +4,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.deepSerializeAxiosErrors = deepSerializeAxiosErrors;
5
5
  const axiosErrorSerializer_1 = require("./axiosErrorSerializer");
6
6
  const isAxiosError_1 = require("./isAxiosError");
7
- const MAX_STRING_LENGTH = 128;
7
+ const DEFAULT_MAX_STRING_LENGTH = 128;
8
+ const ENV_MAX_STRING_LENGTH = Number(process.env.LOG_MAX_STRING_LENGTH);
9
+ const MAX_STRING_LENGTH = Number.isFinite(ENV_MAX_STRING_LENGTH) && ENV_MAX_STRING_LENGTH > 0
10
+ ? Math.floor(ENV_MAX_STRING_LENGTH)
11
+ : DEFAULT_MAX_STRING_LENGTH;
8
12
  function isProbablyBase64(value) {
9
13
  if (!value || value.length < 16 || value.length % 4 !== 0)
10
14
  return false;
@@ -73,6 +73,10 @@ if (lokiEnabled) {
73
73
  }
74
74
  const name = process.env.LOG_NAME || undefined;
75
75
  const transport = pino_1.default.transport({ targets });
76
+ const serializeError = (error) => {
77
+ const base = (0, isAxiosError_1.isAxiosError)(error) ? (0, axiosErrorSerializer_1.axiosErrorSerializer)(error) : pino_1.default.stdSerializers.err(error);
78
+ return (0, deepSerializeAxiosErrors_1.deepSerializeAxiosErrors)(base);
79
+ };
76
80
  const logger = (0, pino_1.default)({
77
81
  name: appName,
78
82
  level,
@@ -83,8 +87,8 @@ const logger = (0, pino_1.default)({
83
87
  },
84
88
  },
85
89
  serializers: {
86
- err: (error) => ((0, isAxiosError_1.isAxiosError)(error) ? (0, axiosErrorSerializer_1.axiosErrorSerializer)(error) : pino_1.default.stdSerializers.err(error)),
87
- error: (error) => ((0, isAxiosError_1.isAxiosError)(error) ? (0, axiosErrorSerializer_1.axiosErrorSerializer)(error) : pino_1.default.stdSerializers.err(error)),
90
+ err: serializeError,
91
+ error: serializeError,
88
92
  axiosError: axiosErrorSerializer_1.axiosErrorSerializer,
89
93
  },
90
94
  formatters: {