lhisp-logger 1.0.13 → 1.0.15
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 +2 -1
- package/src/lhisp-logger.d.ts +2 -1
- package/src/lhisp-logger.js +21 -13
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lhisp-logger",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.15",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "src/lhisp-logger",
|
|
6
6
|
"types": "src/lhisp-logger.d.ts",
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
"typescript": "^5.0.4"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
+
"@logtail/pino": "^0.4.12",
|
|
27
28
|
"pino": "^8.11.0"
|
|
28
29
|
}
|
|
29
30
|
}
|
package/src/lhisp-logger.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const isAxiosError: (error: any) =>
|
|
1
|
+
export declare const isAxiosError: (error: any) => any;
|
|
2
2
|
export declare const axiosErrorSerializer: (err: any) => {
|
|
3
3
|
message: any;
|
|
4
4
|
config: any;
|
|
@@ -41,5 +41,6 @@ declare const logger: import("pino").Logger<{
|
|
|
41
41
|
} | undefined;
|
|
42
42
|
};
|
|
43
43
|
};
|
|
44
|
+
transport: any;
|
|
44
45
|
}>;
|
|
45
46
|
export default logger;
|
package/src/lhisp-logger.js
CHANGED
|
@@ -7,26 +7,34 @@ 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
|
+
err.config.httpsAgent = err.config.httpsAgent ? "[REDACTED]" : undefined;
|
|
15
|
+
return {
|
|
16
|
+
message: err.message,
|
|
17
|
+
config: err.config,
|
|
18
|
+
response: err.response
|
|
19
|
+
? {
|
|
20
|
+
status: err.response.status,
|
|
21
|
+
data: err.response.data,
|
|
22
|
+
headers: err.response.headers,
|
|
23
|
+
}
|
|
24
|
+
: undefined,
|
|
25
|
+
};
|
|
26
|
+
};
|
|
24
27
|
exports.axiosErrorSerializer = axiosErrorSerializer;
|
|
25
28
|
const logger = (0, pino_1.default)(Object.assign({ name: process.env.LOG_NAME || undefined, level: process.env.LOG_LEVEL || "info", serializers: {
|
|
26
29
|
err: (error) => ((0, exports.isAxiosError)(error) ? (0, exports.axiosErrorSerializer)(error) : pino_1.default.stdSerializers.err(error)),
|
|
27
30
|
error: (error) => ((0, exports.isAxiosError)(error) ? (0, exports.axiosErrorSerializer)(error) : pino_1.default.stdSerializers.err(error)),
|
|
28
31
|
axiosError: exports.axiosErrorSerializer,
|
|
29
|
-
}
|
|
32
|
+
}, transport: process.env.LOGTAIL
|
|
33
|
+
? pino_1.default.transport({
|
|
34
|
+
target: "@logtail/pino",
|
|
35
|
+
options: { sourceToken: process.env.LOGTAIL },
|
|
36
|
+
})
|
|
37
|
+
: undefined }, (process.env.LOG_PID_AND_HOSTNAME ? {} : { base: undefined })), process.env.LOG_DESTINATION
|
|
30
38
|
? pino_1.default.destination({
|
|
31
39
|
dest: process.env.LOG_DESTINATION,
|
|
32
40
|
sync: !!process.env.LOG_DESTINATION,
|