idea-aws 4.3.0 → 4.3.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/src/logger.d.ts
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
* Note: the log level is controlled by each Lambda function's configuration.
|
|
4
4
|
*/
|
|
5
5
|
export declare class Logger {
|
|
6
|
-
debug: (
|
|
7
|
-
info: (
|
|
8
|
-
warn: (
|
|
9
|
-
error: (
|
|
6
|
+
debug: (summary: string, content?: object) => void;
|
|
7
|
+
info: (summary: string, content?: object) => void;
|
|
8
|
+
warn: (summary: string, error: Error | any, content?: object) => void;
|
|
9
|
+
error: (summary: string, error: Error | any, content?: object) => void;
|
|
10
10
|
}
|
package/dist/src/logger.js
CHANGED
|
@@ -7,10 +7,10 @@ exports.Logger = void 0;
|
|
|
7
7
|
*/
|
|
8
8
|
class Logger {
|
|
9
9
|
constructor() {
|
|
10
|
-
this.debug = (
|
|
11
|
-
this.info = (
|
|
12
|
-
this.warn = (
|
|
13
|
-
this.error = (
|
|
10
|
+
this.debug = (summary, content = {}) => console.debug({ summary, ...content });
|
|
11
|
+
this.info = (summary, content = {}) => console.info({ summary, ...content });
|
|
12
|
+
this.warn = (summary, error, content = {}) => console.warn({ summary, ...content, error });
|
|
13
|
+
this.error = (summary, error, content = {}) => console.error({ summary, ...content, error });
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
exports.Logger = Logger;
|
|
@@ -37,14 +37,14 @@ export declare abstract class ResourceController extends GenericController {
|
|
|
37
37
|
constructor(event: APIGatewayProxyEventV2 | APIGatewayProxyEvent, callback: Callback, options?: ResourceControllerOptions);
|
|
38
38
|
private initFromEventV2;
|
|
39
39
|
private initFromEventV1;
|
|
40
|
-
protected
|
|
40
|
+
protected getEventSummary(): Record<string, any>;
|
|
41
41
|
/**
|
|
42
42
|
* Force the parsing of a query parameter as an array of strings.
|
|
43
43
|
*/
|
|
44
44
|
protected getQueryParamAsArray(paramName: string): string[];
|
|
45
45
|
handleRequest: () => Promise<void>;
|
|
46
46
|
private remapHandlerError;
|
|
47
|
-
protected done(error?: Error | any,
|
|
47
|
+
protected done(error?: Error | any, rawResult?: any, statusCode?: number): void;
|
|
48
48
|
/**
|
|
49
49
|
* To @override
|
|
50
50
|
*/
|
|
@@ -138,7 +138,7 @@ class ResourceController extends genericController_1.GenericController {
|
|
|
138
138
|
}
|
|
139
139
|
if (options.useMetrics)
|
|
140
140
|
this.prepareMetrics();
|
|
141
|
-
this.logger.info(
|
|
141
|
+
this.logger.info('START', { event: this.getEventSummary() });
|
|
142
142
|
}
|
|
143
143
|
catch (err) {
|
|
144
144
|
this.initError = true;
|
|
@@ -190,8 +190,10 @@ class ResourceController extends genericController_1.GenericController {
|
|
|
190
190
|
throw new RCError('Malformed body');
|
|
191
191
|
}
|
|
192
192
|
}
|
|
193
|
-
|
|
193
|
+
getEventSummary() {
|
|
194
194
|
return {
|
|
195
|
+
httpMethod: this.httpMethod,
|
|
196
|
+
path: this.path,
|
|
195
197
|
principalId: this.principalId,
|
|
196
198
|
queryParams: this.queryParams,
|
|
197
199
|
body: this.body,
|
|
@@ -211,30 +213,29 @@ class ResourceController extends genericController_1.GenericController {
|
|
|
211
213
|
else
|
|
212
214
|
return String(this.queryParams[paramName]).split(',');
|
|
213
215
|
}
|
|
214
|
-
remapHandlerError(err,
|
|
216
|
+
remapHandlerError(err, interceptedInContext, replaceWithMessage) {
|
|
215
217
|
if (err instanceof RCError)
|
|
216
218
|
return err;
|
|
217
219
|
const error = err;
|
|
218
|
-
error.
|
|
220
|
+
error.intercepted = interceptedInContext;
|
|
219
221
|
error.internalMessage = error.message;
|
|
220
222
|
error.message = replaceWithMessage;
|
|
221
223
|
return error;
|
|
222
224
|
}
|
|
223
|
-
done(error,
|
|
224
|
-
const
|
|
225
|
-
if (result)
|
|
226
|
-
logContent.result = Array.isArray(result) ? `Array (${result.length})` : result;
|
|
225
|
+
done(error, rawResult, statusCode = this.returnStatusCode ?? (error ? 400 : 200)) {
|
|
226
|
+
const result = error ? { message: error.message } : rawResult ?? {};
|
|
227
227
|
if (error)
|
|
228
|
-
this.logger.error(
|
|
228
|
+
this.logger.error('END-FAILED', error, { statusCode, event: this.getEventSummary() });
|
|
229
229
|
else
|
|
230
|
-
this.logger.info(
|
|
230
|
+
this.logger.info('END-SUCCESS', { statusCode, event: this.getEventSummary() });
|
|
231
|
+
this.logger.debug('END-DETAIL', Array.isArray(result) ? { array: result.length } : result);
|
|
231
232
|
if (this.logRequestsWithKey)
|
|
232
233
|
this.storeLog(!error);
|
|
233
234
|
if (this.metrics)
|
|
234
235
|
this.publishMetrics(statusCode, error);
|
|
235
236
|
this.callback(null, {
|
|
236
237
|
statusCode: String(statusCode),
|
|
237
|
-
body:
|
|
238
|
+
body: JSON.stringify(result),
|
|
238
239
|
headers: { 'Content-Type': 'application/json', 'Access-Control-Allow-Origin': '*' }
|
|
239
240
|
});
|
|
240
241
|
}
|
|
@@ -9,7 +9,7 @@ class StreamController extends genericController_1.GenericController {
|
|
|
9
9
|
constructor(event, callback) {
|
|
10
10
|
super(event, callback);
|
|
11
11
|
this.records = event.Records ?? [];
|
|
12
|
-
this.logger.info(
|
|
12
|
+
this.logger.info('START STREAM', { records: this.records.length ?? 0 });
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
exports.StreamController = StreamController;
|