unnbound-logger-sdk 3.0.14 → 3.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/dist/index.d.ts +0 -1
- package/dist/index.js +1 -3
- package/dist/logger.js +1 -4
- package/dist/storage.d.ts +1 -0
- package/dist/trace.d.ts +1 -0
- package/dist/trace.js +3 -1
- package/dist/utils.d.ts +0 -7
- package/dist/utils.js +0 -28
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.traceMiddleware = exports.traceAxios = exports.startSpan = exports.getTraceId = exports.withTrace = exports.logger = void 0;
|
|
4
4
|
var logger_1 = require("./logger");
|
|
5
5
|
Object.defineProperty(exports, "logger", { enumerable: true, get: function () { return logger_1.logger; } });
|
|
6
6
|
var trace_1 = require("./trace");
|
|
@@ -12,5 +12,3 @@ var axios_1 = require("./axios");
|
|
|
12
12
|
Object.defineProperty(exports, "traceAxios", { enumerable: true, get: function () { return axios_1.traceAxios; } });
|
|
13
13
|
var middleware_1 = require("./middleware");
|
|
14
14
|
Object.defineProperty(exports, "traceMiddleware", { enumerable: true, get: function () { return middleware_1.traceMiddleware; } });
|
|
15
|
-
var utils_1 = require("./utils");
|
|
16
|
-
Object.defineProperty(exports, "sanitizeLogContent", { enumerable: true, get: function () { return utils_1.sanitizeLogContent; } });
|
package/dist/logger.js
CHANGED
|
@@ -7,7 +7,6 @@ exports.logger = void 0;
|
|
|
7
7
|
const pino_1 = __importDefault(require("pino"));
|
|
8
8
|
const uuid_1 = require("uuid");
|
|
9
9
|
const storage_1 = require("./storage");
|
|
10
|
-
const utils_1 = require("./utils");
|
|
11
10
|
const levels = new Set(['debug', 'info', 'warn', 'error']);
|
|
12
11
|
const hidden = (data) => '_hide' in data && data._hide;
|
|
13
12
|
exports.logger = (0, pino_1.default)({
|
|
@@ -45,9 +44,7 @@ exports.logger = (0, pino_1.default)({
|
|
|
45
44
|
firstArg.level = undefined;
|
|
46
45
|
}
|
|
47
46
|
}
|
|
48
|
-
|
|
49
|
-
const sanitizedArgs = args.map((arg) => (0, utils_1.sanitizeLogContent)(arg));
|
|
50
|
-
method.apply(this, sanitizedArgs);
|
|
47
|
+
method.apply(this, args);
|
|
51
48
|
},
|
|
52
49
|
},
|
|
53
50
|
redact: {
|
package/dist/storage.d.ts
CHANGED
package/dist/trace.d.ts
CHANGED
package/dist/trace.js
CHANGED
|
@@ -16,6 +16,8 @@ exports.getTraceId = getTraceId;
|
|
|
16
16
|
* @returns The result of the callback
|
|
17
17
|
*/
|
|
18
18
|
const withTrace = (callback, extra) => {
|
|
19
|
-
|
|
19
|
+
const previous = storage_1.storage.getStore();
|
|
20
|
+
const traceId = extra?.traceId ?? previous?.traceId ?? (0, exports.getTraceId)();
|
|
21
|
+
return storage_1.storage.run({ ...previous, ...extra, traceId }, callback);
|
|
20
22
|
};
|
|
21
23
|
exports.withTrace = withTrace;
|
package/dist/utils.d.ts
CHANGED
|
@@ -11,13 +11,6 @@ export declare const shouldIgnorePath: (path: string, patterns: string[]) => boo
|
|
|
11
11
|
* @returns Parsed JSON object or the original data.
|
|
12
12
|
*/
|
|
13
13
|
export declare function safeJsonParse(data: any): any;
|
|
14
|
-
/**
|
|
15
|
-
* Sanitizes log content by replacing newlines with carriage returns to prevent
|
|
16
|
-
* CloudWatch from splitting logs into multiple entries.
|
|
17
|
-
* @param obj The object to sanitize
|
|
18
|
-
* @returns Sanitized object with newlines replaced
|
|
19
|
-
*/
|
|
20
|
-
export declare function sanitizeLogContent(obj: any): any;
|
|
21
14
|
/**
|
|
22
15
|
* Normalizes IP addresses by removing IPv6 mapping prefix for IPv4 addresses.
|
|
23
16
|
* @param ip The IP address to normalize.
|
package/dist/utils.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.shouldIgnorePath = void 0;
|
|
4
4
|
exports.safeJsonParse = safeJsonParse;
|
|
5
|
-
exports.sanitizeLogContent = sanitizeLogContent;
|
|
6
5
|
exports.normalizeIp = normalizeIp;
|
|
7
6
|
/**
|
|
8
7
|
* Checks if a path matches any of the ignore patterns
|
|
@@ -38,33 +37,6 @@ function safeJsonParse(data) {
|
|
|
38
37
|
}
|
|
39
38
|
return data;
|
|
40
39
|
}
|
|
41
|
-
/**
|
|
42
|
-
* Sanitizes log content by replacing newlines with carriage returns to prevent
|
|
43
|
-
* CloudWatch from splitting logs into multiple entries.
|
|
44
|
-
* @param obj The object to sanitize
|
|
45
|
-
* @returns Sanitized object with newlines replaced
|
|
46
|
-
*/
|
|
47
|
-
function sanitizeLogContent(obj) {
|
|
48
|
-
if (obj === null || obj === undefined) {
|
|
49
|
-
return obj;
|
|
50
|
-
}
|
|
51
|
-
if (typeof obj === 'string') {
|
|
52
|
-
// Replace \n and \r\n with \r to prevent CloudWatch log splitting
|
|
53
|
-
return obj.replace(/\r?\n/g, '\r');
|
|
54
|
-
}
|
|
55
|
-
if (Array.isArray(obj)) {
|
|
56
|
-
return obj.map(sanitizeLogContent);
|
|
57
|
-
}
|
|
58
|
-
if (typeof obj === 'object') {
|
|
59
|
-
const sanitized = {};
|
|
60
|
-
for (const [key, value] of Object.entries(obj)) {
|
|
61
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
62
|
-
sanitized[key] = sanitizeLogContent(value);
|
|
63
|
-
}
|
|
64
|
-
return sanitized;
|
|
65
|
-
}
|
|
66
|
-
return obj;
|
|
67
|
-
}
|
|
68
40
|
/**
|
|
69
41
|
* Normalizes IP addresses by removing IPv6 mapping prefix for IPv4 addresses.
|
|
70
42
|
* @param ip The IP address to normalize.
|
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.0.
|
|
4
|
+
"version": "3.0.16",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"scripts": {
|