unnbound-logger-sdk 3.0.21 → 3.0.23

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Unnbound Team
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,2 @@
1
+ export declare const encode: (value: string) => string;
2
+ export declare const decode: (value: string) => string;
package/dist/encode.js ADDED
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.decode = exports.encode = void 0;
4
+ const encode = (value) => value.replaceAll('\n', '\r');
5
+ exports.encode = encode;
6
+ const decode = (value) => value.replaceAll('\r', '\n');
7
+ exports.decode = decode;
package/dist/index.d.ts CHANGED
@@ -7,6 +7,7 @@
7
7
  export type { LogLevel, LogType, HttpMethod, Log, HttpPayload, SftpPayload, EdiPayload, EdiOperation, EdiFormat, EdiX12Payload, EdiX12Operation, } from './types';
8
8
  export type { UnnboundLogger } from './logger';
9
9
  export { logger } from './logger';
10
+ export { encode, decode } from './encode';
10
11
  export { withTrace, getTraceId } from './trace';
11
12
  export { startSpan } from './span';
12
13
  export { traceAxios } from './axios';
package/dist/index.js CHANGED
@@ -1,8 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.traceMiddleware = exports.traceAxios = exports.startSpan = exports.getTraceId = exports.withTrace = exports.logger = void 0;
3
+ exports.traceMiddleware = exports.traceAxios = exports.startSpan = exports.getTraceId = exports.withTrace = exports.decode = exports.encode = 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
+ var encode_1 = require("./encode");
7
+ Object.defineProperty(exports, "encode", { enumerable: true, get: function () { return encode_1.encode; } });
8
+ Object.defineProperty(exports, "decode", { enumerable: true, get: function () { return encode_1.decode; } });
6
9
  var trace_1 = require("./trace");
7
10
  Object.defineProperty(exports, "withTrace", { enumerable: true, get: function () { return trace_1.withTrace; } });
8
11
  Object.defineProperty(exports, "getTraceId", { enumerable: true, get: function () { return trace_1.getTraceId; } });
@@ -1 +1,2 @@
1
+ export declare const hidden: (data: object) => unknown;
1
2
  export declare const internal: () => Record<string, unknown>;
package/dist/internal.js CHANGED
@@ -1,10 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.internal = void 0;
3
+ exports.internal = exports.hidden = void 0;
4
4
  const o = { _internal: true };
5
5
  // Internal logs should be hidden in sandbox
6
6
  // TODO: Find a better way to detect sandbox
7
7
  if (process.env.UNNBOUND_IDLE_TIMEOUT)
8
8
  o._hide = true;
9
+ const hidden = (data) => '_hide' in data && data._hide;
10
+ exports.hidden = hidden;
9
11
  const internal = () => o;
10
12
  exports.internal = internal;
package/dist/logger.js CHANGED
@@ -7,8 +7,23 @@ 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 encode_1 = require("./encode");
11
+ const internal_1 = require("./internal");
10
12
  const levels = new Set(['debug', 'info', 'warn', 'error']);
11
- const hidden = (data) => '_hide' in data && data._hide;
13
+ const formatLevel = (level) => ({ level });
14
+ const formatLog = (log) => {
15
+ Object.entries(log).forEach(([key, value]) => {
16
+ if (value && typeof value === 'object') {
17
+ log[key] = formatLog(value);
18
+ return;
19
+ }
20
+ if (typeof value === 'string') {
21
+ log[key] = (0, encode_1.encode)(value);
22
+ return;
23
+ }
24
+ });
25
+ return log;
26
+ };
12
27
  exports.logger = (0, pino_1.default)({
13
28
  level: process.env.LOG_LEVEL ?? 'debug',
14
29
  base: {
@@ -22,21 +37,21 @@ exports.logger = (0, pino_1.default)({
22
37
  req: pino_1.default.stdSerializers.req,
23
38
  res: pino_1.default.stdSerializers.res,
24
39
  err: pino_1.default.stdSerializers.err,
40
+ message: encode_1.encode,
25
41
  },
26
42
  // Let CloudWatch handle timestamps
27
43
  timestamp: false,
28
44
  // Change message field from 'msg' to 'message'
29
45
  messageKey: 'message',
30
- formatters: {
31
- level: (level) => ({ level }),
32
- },
46
+ formatters: { level: formatLevel, log: formatLog },
33
47
  hooks: {
34
48
  logMethod(args, method) {
35
49
  const firstArg = args[0];
36
50
  if (!!firstArg && typeof firstArg === 'object') {
37
- if (hidden(firstArg))
51
+ // If the log entry is considered hidden, don't log it
52
+ if ((0, internal_1.hidden)(firstArg))
38
53
  return;
39
- // Allow dynamic log level
54
+ // Dynamic log level by allowing overwriting the log level
40
55
  if ('level' in firstArg &&
41
56
  typeof firstArg.level === 'string' &&
42
57
  levels.has(firstArg.level)) {
package/package.json CHANGED
@@ -1,23 +1,9 @@
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.21",
4
+ "version": "3.0.23",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
- "scripts": {
8
- "build": "tsc",
9
- "test": "jest",
10
- "test:coverage": "jest --coverage",
11
- "test:watch": "jest --watch",
12
- "typecheck": "tsc -noEmit",
13
- "lint": "eslint --cache --cache-location ./node_modules/.cache/eslint .",
14
- "lint:fix": "pnpm lint --fix",
15
- "format": "prettier --write .",
16
- "format:check": "prettier --check .",
17
- "prepublishOnly": "pnpm build",
18
- "start:example": "npx --yes tsx --watch examples/node-express.ts",
19
- "version:bump": "npm version patch"
20
- },
21
7
  "keywords": [
22
8
  "logging",
23
9
  "typescript",
@@ -71,5 +57,18 @@
71
57
  "engines": {
72
58
  "node": ">=22"
73
59
  },
74
- "sideEffects": false
75
- }
60
+ "sideEffects": false,
61
+ "scripts": {
62
+ "build": "tsc",
63
+ "test": "jest",
64
+ "test:coverage": "jest --coverage",
65
+ "test:watch": "jest --watch",
66
+ "typecheck": "tsc -noEmit",
67
+ "lint": "eslint --cache --cache-location ./node_modules/.cache/eslint .",
68
+ "lint:fix": "pnpm lint --fix",
69
+ "format": "prettier --write .",
70
+ "format:check": "prettier --check .",
71
+ "start:example": "npx --yes tsx --watch examples/node-express.ts",
72
+ "version:bump": "npm version patch"
73
+ }
74
+ }