lhisp-logger 1.0.14 → 1.0.16
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 +1 -1
- package/src/lhisp-logger.d.ts +1 -1
- package/src/lhisp-logger.js +21 -12
package/package.json
CHANGED
package/src/lhisp-logger.d.ts
CHANGED
package/src/lhisp-logger.js
CHANGED
|
@@ -7,20 +7,29 @@ exports.axiosErrorSerializer = exports.isAxiosError = void 0;
|
|
|
7
7
|
const pino_1 = __importDefault(require("pino"));
|
|
8
8
|
const isAxiosError = (error) => {
|
|
9
9
|
const isObject = error !== null && typeof error === "object";
|
|
10
|
-
return isObject && error
|
|
10
|
+
return isObject && (error === null || error === void 0 ? void 0 : error.config);
|
|
11
11
|
};
|
|
12
12
|
exports.isAxiosError = isAxiosError;
|
|
13
|
-
const axiosErrorSerializer = (err) =>
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
:
|
|
23
|
-
|
|
13
|
+
const axiosErrorSerializer = (err) => {
|
|
14
|
+
var _a, _b;
|
|
15
|
+
if ((_a = err === null || err === void 0 ? void 0 : err.config) === null || _a === void 0 ? void 0 : _a.httpsAgent)
|
|
16
|
+
err.config.httpsAgent = err.config.httpsAgent ? "[REDACTED]" : undefined;
|
|
17
|
+
if ((_b = err === null || err === void 0 ? void 0 : err.config) === null || _b === void 0 ? void 0 : _b.headers) {
|
|
18
|
+
err.config.headers.Authorization = err.config.headers.Authorization ? "[REDACTED]" : undefined;
|
|
19
|
+
err.config.headers.authorization = err.config.headers.authorization ? "[REDACTED]" : undefined;
|
|
20
|
+
}
|
|
21
|
+
return {
|
|
22
|
+
message: err.message,
|
|
23
|
+
config: err.config,
|
|
24
|
+
response: err.response
|
|
25
|
+
? {
|
|
26
|
+
status: err.response.status,
|
|
27
|
+
data: err.response.data,
|
|
28
|
+
headers: err.response.headers,
|
|
29
|
+
}
|
|
30
|
+
: undefined,
|
|
31
|
+
};
|
|
32
|
+
};
|
|
24
33
|
exports.axiosErrorSerializer = axiosErrorSerializer;
|
|
25
34
|
const logger = (0, pino_1.default)(Object.assign({ name: process.env.LOG_NAME || undefined, level: process.env.LOG_LEVEL || "info", serializers: {
|
|
26
35
|
err: (error) => ((0, exports.isAxiosError)(error) ? (0, exports.axiosErrorSerializer)(error) : pino_1.default.stdSerializers.err(error)),
|