lhisp-logger 1.0.15 → 1.0.17
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 +5 -3
- package/src/axiosErrorSerializer.d.ts +9 -0
- package/src/axiosErrorSerializer.js +24 -0
- package/src/isAxiosError.d.ts +1 -0
- package/src/isAxiosError.js +8 -0
- package/src/lhisp-logger.d.ts +1 -12
- package/src/lhisp-logger.js +22 -28
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lhisp-logger",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.17",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "src/lhisp-logger",
|
|
6
6
|
"types": "src/lhisp-logger.d.ts",
|
|
7
7
|
"scripts": {
|
|
8
|
-
"build": "tsc"
|
|
8
|
+
"build": "tsc",
|
|
9
|
+
"test": "echo NO TESTS"
|
|
9
10
|
},
|
|
10
11
|
"repository": {
|
|
11
12
|
"type": "git",
|
|
@@ -25,6 +26,7 @@
|
|
|
25
26
|
},
|
|
26
27
|
"dependencies": {
|
|
27
28
|
"@logtail/pino": "^0.4.12",
|
|
28
|
-
"pino": "^8.11.0"
|
|
29
|
+
"pino": "^8.11.0",
|
|
30
|
+
"pino-pretty": "^13.1.1"
|
|
29
31
|
}
|
|
30
32
|
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.axiosErrorSerializer = void 0;
|
|
4
|
+
const axiosErrorSerializer = (err) => {
|
|
5
|
+
var _a, _b;
|
|
6
|
+
if ((_a = err === null || err === void 0 ? void 0 : err.config) === null || _a === void 0 ? void 0 : _a.httpsAgent)
|
|
7
|
+
err.config.httpsAgent = err.config.httpsAgent ? "[REDACTED]" : undefined;
|
|
8
|
+
if ((_b = err === null || err === void 0 ? void 0 : err.config) === null || _b === void 0 ? void 0 : _b.headers) {
|
|
9
|
+
err.config.headers.Authorization = err.config.headers.Authorization ? "[REDACTED]" : undefined;
|
|
10
|
+
err.config.headers.authorization = err.config.headers.authorization ? "[REDACTED]" : undefined;
|
|
11
|
+
}
|
|
12
|
+
return {
|
|
13
|
+
message: err.message,
|
|
14
|
+
config: err.config,
|
|
15
|
+
response: err.response
|
|
16
|
+
? {
|
|
17
|
+
status: err.response.status,
|
|
18
|
+
data: err.response.data,
|
|
19
|
+
headers: err.response.headers,
|
|
20
|
+
}
|
|
21
|
+
: undefined,
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
exports.axiosErrorSerializer = axiosErrorSerializer;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const isAxiosError: (error: any) => any;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isAxiosError = void 0;
|
|
4
|
+
const isAxiosError = (error) => {
|
|
5
|
+
const isObject = error !== null && typeof error === "object";
|
|
6
|
+
return isObject && (error === null || error === void 0 ? void 0 : error.config);
|
|
7
|
+
};
|
|
8
|
+
exports.isAxiosError = isAxiosError;
|
package/src/lhisp-logger.d.ts
CHANGED
|
@@ -1,15 +1,4 @@
|
|
|
1
|
-
export declare const
|
|
2
|
-
export declare const axiosErrorSerializer: (err: any) => {
|
|
3
|
-
message: any;
|
|
4
|
-
config: any;
|
|
5
|
-
response: {
|
|
6
|
-
status: any;
|
|
7
|
-
data: any;
|
|
8
|
-
headers: any;
|
|
9
|
-
} | undefined;
|
|
10
|
-
};
|
|
11
|
-
declare const logger: import("pino").Logger<{
|
|
12
|
-
base?: undefined;
|
|
1
|
+
export declare const logger: import("pino").Logger<{
|
|
13
2
|
name: string | undefined;
|
|
14
3
|
level: string;
|
|
15
4
|
serializers: {
|
package/src/lhisp-logger.js
CHANGED
|
@@ -3,38 +3,32 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.logger = void 0;
|
|
7
7
|
const pino_1 = __importDefault(require("pino"));
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
? {
|
|
20
|
-
status: err.response.status,
|
|
21
|
-
data: err.response.data,
|
|
22
|
-
headers: err.response.headers,
|
|
23
|
-
}
|
|
24
|
-
: undefined,
|
|
25
|
-
};
|
|
26
|
-
};
|
|
27
|
-
exports.axiosErrorSerializer = axiosErrorSerializer;
|
|
28
|
-
const logger = (0, pino_1.default)(Object.assign({ name: process.env.LOG_NAME || undefined, level: process.env.LOG_LEVEL || "info", serializers: {
|
|
29
|
-
err: (error) => ((0, exports.isAxiosError)(error) ? (0, exports.axiosErrorSerializer)(error) : pino_1.default.stdSerializers.err(error)),
|
|
30
|
-
error: (error) => ((0, exports.isAxiosError)(error) ? (0, exports.axiosErrorSerializer)(error) : pino_1.default.stdSerializers.err(error)),
|
|
31
|
-
axiosError: exports.axiosErrorSerializer,
|
|
32
|
-
}, transport: process.env.LOGTAIL
|
|
8
|
+
const axiosErrorSerializer_1 = require("./axiosErrorSerializer");
|
|
9
|
+
const isAxiosError_1 = require("./isAxiosError");
|
|
10
|
+
exports.logger = (0, pino_1.default)({
|
|
11
|
+
name: process.env.LOG_NAME || undefined,
|
|
12
|
+
level: process.env.LOG_LEVEL || "info",
|
|
13
|
+
serializers: {
|
|
14
|
+
err: (error) => ((0, isAxiosError_1.isAxiosError)(error) ? (0, axiosErrorSerializer_1.axiosErrorSerializer)(error) : pino_1.default.stdSerializers.err(error)),
|
|
15
|
+
error: (error) => ((0, isAxiosError_1.isAxiosError)(error) ? (0, axiosErrorSerializer_1.axiosErrorSerializer)(error) : pino_1.default.stdSerializers.err(error)),
|
|
16
|
+
axiosError: axiosErrorSerializer_1.axiosErrorSerializer,
|
|
17
|
+
},
|
|
18
|
+
transport: process.env.LOGTAIL
|
|
33
19
|
? pino_1.default.transport({
|
|
34
20
|
target: "@logtail/pino",
|
|
35
21
|
options: { sourceToken: process.env.LOGTAIL },
|
|
36
22
|
})
|
|
37
|
-
:
|
|
23
|
+
: {
|
|
24
|
+
target: "pino-pretty",
|
|
25
|
+
options: {
|
|
26
|
+
colorize: true,
|
|
27
|
+
ignore: "pid,hostname",
|
|
28
|
+
translateTime: "yyyy-mm-dd HH:MM:ss",
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
}, process.env.LOG_DESTINATION
|
|
38
32
|
? pino_1.default.destination({
|
|
39
33
|
dest: process.env.LOG_DESTINATION,
|
|
40
34
|
sync: !!process.env.LOG_DESTINATION,
|
|
@@ -42,4 +36,4 @@ const logger = (0, pino_1.default)(Object.assign({ name: process.env.LOG_NAME ||
|
|
|
42
36
|
: process.env.LOG_SYNC
|
|
43
37
|
? pino_1.default.destination({ sync: true })
|
|
44
38
|
: pino_1.default.destination(1));
|
|
45
|
-
exports.default = logger;
|
|
39
|
+
exports.default = exports.logger;
|