unnbound-logger-sdk 3.2.0 → 3.2.1
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/dist/logger.js +13 -2
- package/package.json +1 -1
package/dist/logger.js
CHANGED
|
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.logger = exports.createLogger = void 0;
|
|
7
|
+
const axios_1 = require("axios");
|
|
7
8
|
const pino_1 = __importDefault(require("pino"));
|
|
8
9
|
const uuid_1 = require("uuid");
|
|
9
10
|
const encode_1 = require("./encode");
|
|
@@ -26,6 +27,16 @@ const isStringAnnotation = (value) => {
|
|
|
26
27
|
return false;
|
|
27
28
|
}
|
|
28
29
|
};
|
|
30
|
+
// An AxiosError carries its config, the Node request (whose `_header` holds every request header, credentials
|
|
31
|
+
// included), and the response. Those three are dropped; the rest of the standard error fields stay (`type`, `message`,
|
|
32
|
+
// `stack`, `code`, `status`). `traceAxios` logs the exchange itself under its own redaction.
|
|
33
|
+
const serializeError = (error) => {
|
|
34
|
+
const serialized = pino_1.default.stdSerializers.err(error);
|
|
35
|
+
if (!(0, axios_1.isAxiosError)(error) || !isBindings(serialized))
|
|
36
|
+
return serialized;
|
|
37
|
+
const { config: _config, request: _request, response: _response, ...kept } = serialized;
|
|
38
|
+
return kept;
|
|
39
|
+
};
|
|
29
40
|
const copyLogFields = (log, copy, copies, preserveErrorSerializer) => {
|
|
30
41
|
for (const key in log) {
|
|
31
42
|
if (!Object.hasOwn(log, key))
|
|
@@ -56,7 +67,7 @@ const copyLogValue = (value, copies) => {
|
|
|
56
67
|
return copy;
|
|
57
68
|
}
|
|
58
69
|
if (value instanceof Error) {
|
|
59
|
-
const serialized =
|
|
70
|
+
const serialized = serializeError(value);
|
|
60
71
|
const copy = {};
|
|
61
72
|
copies.set(value, copy);
|
|
62
73
|
copies.set(serialized, copy);
|
|
@@ -90,7 +101,7 @@ const copyBindings = (log, copies, preserveErrorSerializer) => {
|
|
|
90
101
|
const formatLog = (log) => copyBindings(log, new WeakMap(), true);
|
|
91
102
|
// `err` may be anything thrown; pino returns non-Error values unchanged, so only objects are copied.
|
|
92
103
|
const formatError = (error) => {
|
|
93
|
-
const serialized =
|
|
104
|
+
const serialized = serializeError(error);
|
|
94
105
|
if (isStringAnnotation(serialized))
|
|
95
106
|
return (0, encode_1.encode)(serialized);
|
|
96
107
|
return isBindings(serialized) ? formatLog(serialized) : serialized;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "unnbound-logger-sdk",
|
|
3
3
|
"description": "A structured logging library with TypeScript support using Pino. Provides consistent, well-typed logging with automatic logId, workflowId, traceId, and deploymentId tracking across operational contexts.",
|
|
4
|
-
"version": "3.2.
|
|
4
|
+
"version": "3.2.1",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"keywords": [
|