@devrev/ts-adaas 1.11.1-beta.27 → 1.11.1-beta.29
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/logger.d.ts +16 -6
- package/dist/logger/logger.d.ts.map +1 -1
- package/dist/logger/logger.js +31 -24
- package/dist/logger/logger.test.js +55 -11
- package/dist/types/workers.d.ts +1 -1
- package/dist/types/workers.d.ts.map +1 -1
- package/dist/workers/spawn.js +3 -3
- package/dist/workers/worker.js +0 -2
- package/package.json +1 -1
package/dist/logger/logger.d.ts
CHANGED
|
@@ -26,15 +26,25 @@ export declare class Logger extends Console {
|
|
|
26
26
|
*/
|
|
27
27
|
private truncateMessage;
|
|
28
28
|
/**
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
* In
|
|
29
|
+
* Logs a pre-formatted message string to the console.
|
|
30
|
+
* In production mode, wraps the message with JSON formatting and event context tags.
|
|
31
|
+
* In local development mode, logs the message directly without JSON wrapping.
|
|
32
|
+
* This is useful when you need to log already-stringified content.
|
|
32
33
|
*
|
|
33
|
-
* @param
|
|
34
|
+
* @param message - The pre-formatted message string to log
|
|
34
35
|
* @param level - Log level (info, warn, error)
|
|
35
|
-
* @param skipSanitization - Skip string conversion if args are already strings
|
|
36
36
|
*/
|
|
37
|
-
logFn(
|
|
37
|
+
logFn(message: string, level: LogLevel): void;
|
|
38
|
+
/**
|
|
39
|
+
* Stringifies and logs arguments to the appropriate destination.
|
|
40
|
+
* On main thread, converts arguments to strings and calls logFn.
|
|
41
|
+
* In worker threads, forwards stringified arguments to the main thread for processing.
|
|
42
|
+
* All arguments are converted to strings using util.inspect and joined with spaces.
|
|
43
|
+
*
|
|
44
|
+
* @param args - Values to log (will be stringified and truncated if needed)
|
|
45
|
+
* @param level - Log level (info, warn, error)
|
|
46
|
+
*/
|
|
47
|
+
private stringifyAndLog;
|
|
38
48
|
log(...args: unknown[]): void;
|
|
39
49
|
info(...args: unknown[]): void;
|
|
40
50
|
warn(...args: unknown[]): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/logger/logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAyC,MAAM,OAAO,CAAC;AAE1E,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAQvC,OAAO,EACL,kBAAkB,EAClB,sBAAsB,EAEtB,QAAQ,EAER,cAAc,EACf,MAAM,qBAAqB,CAAC;AAE7B;;;GAGG;AACH,qBAAa,MAAO,SAAQ,OAAO;IACjC,OAAO,CAAC,eAAe,CAAU;IACjC,OAAO,CAAC,OAAO,CAAC,CAAuB;IACvC,OAAO,CAAC,IAAI,CAAa;gBAEb,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,sBAAsB;IAUtD;;;;;OAKG;IACH,OAAO,CAAC,aAAa;IAOrB;;;;;;OAMG;IACH,OAAO,CAAC,eAAe;IASvB;;;;;;;;OAQG;IACH,KAAK,CAAC,
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/logger/logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAyC,MAAM,OAAO,CAAC;AAE1E,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAQvC,OAAO,EACL,kBAAkB,EAClB,sBAAsB,EAEtB,QAAQ,EAER,cAAc,EACf,MAAM,qBAAqB,CAAC;AAE7B;;;GAGG;AACH,qBAAa,MAAO,SAAQ,OAAO;IACjC,OAAO,CAAC,eAAe,CAAU;IACjC,OAAO,CAAC,OAAO,CAAC,CAAuB;IACvC,OAAO,CAAC,IAAI,CAAa;gBAEb,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,sBAAsB;IAUtD;;;;;OAKG;IACH,OAAO,CAAC,aAAa;IAOrB;;;;;;OAMG;IACH,OAAO,CAAC,eAAe;IASvB;;;;;;;;OAQG;IACH,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,GAAG,IAAI;IAa7C;;;;;;;;OAQG;IACH,OAAO,CAAC,eAAe;IAcd,GAAG,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;IAI7B,IAAI,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;IAI9B,IAAI,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;IAI9B,KAAK,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;CAGzC;AAED;;;;;;;GAOG;AAEH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,cAAc,CAqB5E;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAKtD;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,UAAU,GAAG,kBAAkB,CAwBzE;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAE1D"}
|
package/dist/logger/logger.js
CHANGED
|
@@ -50,49 +50,56 @@ class Logger extends node_console_1.Console {
|
|
|
50
50
|
return message;
|
|
51
51
|
}
|
|
52
52
|
/**
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
* In
|
|
53
|
+
* Logs a pre-formatted message string to the console.
|
|
54
|
+
* In production mode, wraps the message with JSON formatting and event context tags.
|
|
55
|
+
* In local development mode, logs the message directly without JSON wrapping.
|
|
56
|
+
* This is useful when you need to log already-stringified content.
|
|
56
57
|
*
|
|
57
|
-
* @param
|
|
58
|
+
* @param message - The pre-formatted message string to log
|
|
58
59
|
* @param level - Log level (info, warn, error)
|
|
59
|
-
* @param skipSanitization - Skip string conversion if args are already strings
|
|
60
60
|
*/
|
|
61
|
-
logFn(
|
|
61
|
+
logFn(message, level) {
|
|
62
62
|
var _a;
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
63
|
+
if ((_a = this.options) === null || _a === void 0 ? void 0 : _a.isLocalDevelopment) {
|
|
64
|
+
this.originalConsole[level](message);
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
const logObject = Object.assign({ message }, this.tags);
|
|
68
|
+
this.originalConsole[level](JSON.stringify(logObject));
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Stringifies and logs arguments to the appropriate destination.
|
|
72
|
+
* On main thread, converts arguments to strings and calls logFn.
|
|
73
|
+
* In worker threads, forwards stringified arguments to the main thread for processing.
|
|
74
|
+
* All arguments are converted to strings using util.inspect and joined with spaces.
|
|
75
|
+
*
|
|
76
|
+
* @param args - Values to log (will be stringified and truncated if needed)
|
|
77
|
+
* @param level - Log level (info, warn, error)
|
|
78
|
+
*/
|
|
79
|
+
stringifyAndLog(args, level) {
|
|
80
|
+
let stringifiedArgs = args.map((arg) => this.valueToString(arg)).join(' ');
|
|
81
|
+
stringifiedArgs = this.truncateMessage(stringifiedArgs);
|
|
67
82
|
if (node_worker_threads_1.isMainThread) {
|
|
68
|
-
|
|
69
|
-
this.originalConsole[level](message);
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
else {
|
|
73
|
-
const logObject = Object.assign({ message }, this.tags);
|
|
74
|
-
this.originalConsole[level](JSON.stringify(logObject));
|
|
75
|
-
}
|
|
83
|
+
this.logFn(stringifiedArgs, level);
|
|
76
84
|
}
|
|
77
85
|
else {
|
|
78
|
-
const sanitizedArgs = args.map((arg) => this.valueToString(arg));
|
|
79
86
|
node_worker_threads_1.parentPort === null || node_worker_threads_1.parentPort === void 0 ? void 0 : node_worker_threads_1.parentPort.postMessage({
|
|
80
87
|
subject: workers_1.WorkerMessageSubject.WorkerMessageLog,
|
|
81
|
-
payload: {
|
|
88
|
+
payload: { stringifiedArgs, level },
|
|
82
89
|
});
|
|
83
90
|
}
|
|
84
91
|
}
|
|
85
92
|
log(...args) {
|
|
86
|
-
this.
|
|
93
|
+
this.stringifyAndLog(args, logger_interfaces_1.LogLevel.INFO);
|
|
87
94
|
}
|
|
88
95
|
info(...args) {
|
|
89
|
-
this.
|
|
96
|
+
this.stringifyAndLog(args, logger_interfaces_1.LogLevel.INFO);
|
|
90
97
|
}
|
|
91
98
|
warn(...args) {
|
|
92
|
-
this.
|
|
99
|
+
this.stringifyAndLog(args, logger_interfaces_1.LogLevel.WARN);
|
|
93
100
|
}
|
|
94
101
|
error(...args) {
|
|
95
|
-
this.
|
|
102
|
+
this.stringifyAndLog(args, logger_interfaces_1.LogLevel.ERROR);
|
|
96
103
|
}
|
|
97
104
|
}
|
|
98
105
|
exports.Logger = Logger;
|
|
@@ -131,26 +131,71 @@ describe(logger_1.Logger.name, () => {
|
|
|
131
131
|
const logObject = JSON.parse(callArgs);
|
|
132
132
|
expect(logObject.message).toBe(shortString);
|
|
133
133
|
});
|
|
134
|
-
it('should
|
|
134
|
+
it('[edge] should not truncate message exactly at maximum length', () => {
|
|
135
135
|
// Arrange
|
|
136
|
-
const
|
|
136
|
+
const messageAtLimit = 'A'.repeat(logger_constants_1.MAX_LOG_STRING_LENGTH);
|
|
137
137
|
const logger = new logger_1.Logger({ event: mockEvent, options: mockOptions });
|
|
138
138
|
// Act
|
|
139
|
-
|
|
140
|
-
|
|
139
|
+
logger.info(messageAtLimit);
|
|
140
|
+
// Assert
|
|
141
|
+
const callArgs = mockConsoleInfo.mock.calls[0][0];
|
|
142
|
+
const logObject = JSON.parse(callArgs);
|
|
143
|
+
expect(logObject.message).toBe(messageAtLimit);
|
|
144
|
+
expect(logObject.message.length).toBe(logger_constants_1.MAX_LOG_STRING_LENGTH);
|
|
145
|
+
});
|
|
146
|
+
it('[edge] should truncate message one character over maximum length', () => {
|
|
147
|
+
// Arrange
|
|
148
|
+
const messageOverLimit = 'B'.repeat(logger_constants_1.MAX_LOG_STRING_LENGTH + 1);
|
|
149
|
+
const logger = new logger_1.Logger({ event: mockEvent, options: mockOptions });
|
|
150
|
+
const expectedMessage = `${messageOverLimit.substring(0, logger_constants_1.MAX_LOG_STRING_LENGTH)}... 1 more characters`;
|
|
151
|
+
// Act
|
|
152
|
+
logger.info(messageOverLimit);
|
|
153
|
+
// Assert
|
|
154
|
+
const callArgs = mockConsoleInfo.mock.calls[0][0];
|
|
155
|
+
const logObject = JSON.parse(callArgs);
|
|
156
|
+
expect(logObject.message).toBe(expectedMessage);
|
|
157
|
+
});
|
|
158
|
+
it('[edge] should handle empty string without truncation', () => {
|
|
159
|
+
// Arrange
|
|
160
|
+
const logger = new logger_1.Logger({ event: mockEvent, options: mockOptions });
|
|
161
|
+
// Act
|
|
162
|
+
logger.info('');
|
|
163
|
+
// Assert
|
|
164
|
+
const callArgs = mockConsoleInfo.mock.calls[0][0];
|
|
165
|
+
const logObject = JSON.parse(callArgs);
|
|
166
|
+
expect(logObject.message).toBe('');
|
|
167
|
+
});
|
|
168
|
+
it('[edge] should show correct character count for very long messages', () => {
|
|
169
|
+
// Arrange
|
|
170
|
+
const veryLongString = 'X'.repeat(50000);
|
|
171
|
+
const logger = new logger_1.Logger({ event: mockEvent, options: mockOptions });
|
|
172
|
+
const expectedCharactersRemaining = 50000 - logger_constants_1.MAX_LOG_STRING_LENGTH;
|
|
173
|
+
const expectedMessage = `${veryLongString.substring(0, logger_constants_1.MAX_LOG_STRING_LENGTH)}... ${expectedCharactersRemaining} more characters`;
|
|
174
|
+
// Act
|
|
175
|
+
logger.info(veryLongString);
|
|
141
176
|
// Assert
|
|
142
177
|
const callArgs = mockConsoleInfo.mock.calls[0][0];
|
|
143
178
|
const logObject = JSON.parse(callArgs);
|
|
144
|
-
expect(logObject.message).toBe(
|
|
179
|
+
expect(logObject.message).toBe(expectedMessage);
|
|
180
|
+
expect(logObject.message).toContain('40000 more characters');
|
|
145
181
|
});
|
|
146
|
-
it('should
|
|
182
|
+
it('should stringify string arguments and join them with spaces', () => {
|
|
183
|
+
// Arrange
|
|
184
|
+
const logger = new logger_1.Logger({ event: mockEvent, options: mockOptions });
|
|
185
|
+
// Act
|
|
186
|
+
logger.info('Message 1', 'Message 2');
|
|
187
|
+
// Assert
|
|
188
|
+
const callArgs = mockConsoleInfo.mock.calls[0][0];
|
|
189
|
+
const logObject = JSON.parse(callArgs);
|
|
190
|
+
expect(logObject.message).toBe('Message 1 Message 2');
|
|
191
|
+
});
|
|
192
|
+
it('should stringify object arguments using util.inspect', () => {
|
|
147
193
|
// Arrange
|
|
148
194
|
const data = { id: 123 };
|
|
149
195
|
const logger = new logger_1.Logger({ event: mockEvent, options: mockOptions });
|
|
150
196
|
const expectedMessage = (0, node_util_1.inspect)(data, logger_constants_1.INSPECT_OPTIONS);
|
|
151
197
|
// Act
|
|
152
|
-
|
|
153
|
-
logger.logFn([data], 'info', false);
|
|
198
|
+
logger.info(data);
|
|
154
199
|
// Assert
|
|
155
200
|
const callArgs = mockConsoleInfo.mock.calls[0][0];
|
|
156
201
|
const logObject = JSON.parse(callArgs);
|
|
@@ -188,12 +233,11 @@ describe(logger_1.Logger.name, () => {
|
|
|
188
233
|
// Assert
|
|
189
234
|
expect(mockConsoleError).toHaveBeenCalledTimes(1);
|
|
190
235
|
});
|
|
191
|
-
it('[edge] should
|
|
236
|
+
it('[edge] should log empty string as valid message with tags', () => {
|
|
192
237
|
// Arrange
|
|
193
|
-
const emptyString = '';
|
|
194
238
|
const logger = new logger_1.Logger({ event: mockEvent, options: mockOptions });
|
|
195
239
|
// Act
|
|
196
|
-
logger.info(
|
|
240
|
+
logger.info('');
|
|
197
241
|
// Assert
|
|
198
242
|
const callArgs = mockConsoleInfo.mock.calls[0][0];
|
|
199
243
|
const logObject = JSON.parse(callArgs);
|
package/dist/types/workers.d.ts
CHANGED
|
@@ -42,7 +42,7 @@ export interface SpawnInterface {
|
|
|
42
42
|
worker: Worker;
|
|
43
43
|
options?: WorkerAdapterOptions;
|
|
44
44
|
resolve: (value: void | PromiseLike<void>) => void;
|
|
45
|
-
originalConsole
|
|
45
|
+
originalConsole?: Console;
|
|
46
46
|
}
|
|
47
47
|
/**
|
|
48
48
|
* SpawnFactoryInterface is an interface for Spawn class factory.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workers.d.ts","sourceRoot":"","sources":["../../src/types/workers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAExC,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE1D,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAEhE,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAE5C,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAEhD;;;;;;;GAOG;AACH,MAAM,WAAW,sBAAsB,CAAC,cAAc;IACpD,KAAK,EAAE,YAAY,CAAC;IACpB,YAAY,EAAE,KAAK,CAAC,cAAc,CAAC,CAAC;IACpC,OAAO,CAAC,EAAE,oBAAoB,CAAC;CAChC;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,oBAAoB;IACnC,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,YAAY,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,oBAAoB,CAAC;IAC/B,OAAO,EAAE,CAAC,KAAK,EAAE,IAAI,GAAG,WAAW,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC;IACnD,eAAe,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"workers.d.ts","sourceRoot":"","sources":["../../src/types/workers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAExC,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE1D,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAEhE,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAE5C,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAEhD;;;;;;;GAOG;AACH,MAAM,WAAW,sBAAsB,CAAC,cAAc;IACpD,KAAK,EAAE,YAAY,CAAC;IACpB,YAAY,EAAE,KAAK,CAAC,cAAc,CAAC,CAAC;IACpC,OAAO,CAAC,EAAE,oBAAoB,CAAC;CAChC;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,oBAAoB;IACnC,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,YAAY,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,oBAAoB,CAAC;IAC/B,OAAO,EAAE,CAAC,KAAK,EAAE,IAAI,GAAG,WAAW,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC;IACnD,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,qBAAqB,CAAC,cAAc;IACnD,KAAK,EAAE,YAAY,CAAC;IACpB,YAAY,EAAE,cAAc,CAAC;IAC7B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,oBAAoB,CAAC;IAC/B,oBAAoB,CAAC,EAAE,oBAAoB,CAAC;CAC7C;AAED;;;;;GAKG;AACH,MAAM,WAAW,oBAAoB,CAAC,cAAc;IAClD,OAAO,EAAE,aAAa,CAAC,cAAc,CAAC,CAAC;CACxC;AAED;;;;;;GAMG;AACH,MAAM,WAAW,oBAAoB,CAAC,cAAc;IAClD,IAAI,EAAE,CAAC,MAAM,EAAE,oBAAoB,CAAC,cAAc,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACtE,SAAS,EAAE,CAAC,MAAM,EAAE,oBAAoB,CAAC,cAAc,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAC5E;AAED;;GAEG;AACH,oBAAY,WAAW;IACrB,aAAa,YAAY;IACzB,YAAY,WAAW;IACvB,WAAW,UAAU;IACrB,UAAU,SAAS;CACpB;AAED;;GAEG;AACH,oBAAY,oBAAoB;IAC9B,oBAAoB,SAAS;IAC7B,iBAAiB,SAAS;IAC1B,gBAAgB,QAAQ;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,oBAAoB,CAAC,oBAAoB,CAAC;IACnD,OAAO,EAAE;QACP,SAAS,EAAE,kBAAkB,GAAG,eAAe,CAAC;KACjD,CAAC;CACH;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,oBAAoB,CAAC,iBAAiB,CAAC;CACjD;AAED;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,oBAAoB,GAAG,iBAAiB,CAAC;AAErE;;GAEG;AACH,MAAM,WAAW,UAAU,CAAC,cAAc;IACxC,KAAK,EAAE,YAAY,CAAC;IACpB,YAAY,EAAE,cAAc,CAAC;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,oBAAoB,CAAC,EAAE,oBAAoB,CAAC;IAC5C,OAAO,CAAC,EAAE,oBAAoB,CAAC;CAChC;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,KAAK,EAAE,YAAY,CAAC;IACpB,mBAAmB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACrC"}
|
package/dist/workers/spawn.js
CHANGED
|
@@ -141,7 +141,7 @@ async function spawn({ event, initialState, workerPath, initialDomainMapping, op
|
|
|
141
141
|
class Spawn {
|
|
142
142
|
constructor({ event, worker, options, resolve, originalConsole, }) {
|
|
143
143
|
this.defaultLambdaTimeout = constants_1.DEFAULT_LAMBDA_TIMEOUT;
|
|
144
|
-
this.originalConsole = originalConsole;
|
|
144
|
+
this.originalConsole = originalConsole || console;
|
|
145
145
|
this.alreadyEmitted = false;
|
|
146
146
|
this.event = event;
|
|
147
147
|
this.lambdaTimeout = (options === null || options === void 0 ? void 0 : options.timeout)
|
|
@@ -184,10 +184,10 @@ class Spawn {
|
|
|
184
184
|
// Since it is not possible to log from the worker thread, we need to log
|
|
185
185
|
// from the main thread.
|
|
186
186
|
if ((message === null || message === void 0 ? void 0 : message.subject) === workers_1.WorkerMessageSubject.WorkerMessageLog) {
|
|
187
|
-
const
|
|
187
|
+
const stringifiedArgs = (_a = message.payload) === null || _a === void 0 ? void 0 : _a.stringifiedArgs;
|
|
188
188
|
const level = (_b = message.payload) === null || _b === void 0 ? void 0 : _b.level;
|
|
189
189
|
// Args are already sanitized in the worker thread, skip double sanitization
|
|
190
|
-
console.logFn(
|
|
190
|
+
console.logFn(stringifiedArgs, level);
|
|
191
191
|
}
|
|
192
192
|
// If worker sends a message that it has emitted an event, then set alreadyEmitted to true.
|
|
193
193
|
if ((message === null || message === void 0 ? void 0 : message.subject) === workers_1.WorkerMessageSubject.WorkerMessageEmitted) {
|
package/dist/workers/worker.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
const { workerData } = require('worker_threads');
|
|
3
3
|
require('ts-node').register();
|
|
4
|
-
// Override console with Logger instance
|
|
5
4
|
const { Logger } = require('../logger/logger');
|
|
6
5
|
// eslint-disable-next-line no-global-assign
|
|
7
6
|
console = new Logger({ event: workerData.event, options: workerData.options });
|
|
8
|
-
// Now load the actual worker with console already overridden
|
|
9
7
|
require(workerData.workerPath);
|
package/package.json
CHANGED