Skip to content

Commit 1bc83be

Browse files
authored
Update debug-lib.js
1 parent f64ad66 commit 1bc83be

File tree

1 file changed

+9
-21
lines changed

1 file changed

+9
-21
lines changed

libs/debug-lib.js

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
1-
import AWS from "aws-sdk";
21
import util from "util";
2+
import AWS from "aws-sdk";
3+
4+
let logs;
35

46
// Log AWS SDK calls
57
AWS.config.logger = { log: debug };
68

7-
let logs;
8-
let timeoutTimer;
9+
export default function debug() {
10+
logs.push({
11+
date: new Date(),
12+
string: util.format.apply(null, arguments),
13+
});
14+
}
915

1016
export function init(event, context) {
1117
logs = [];
@@ -16,27 +22,9 @@ export function init(event, context) {
1622
pathParameters: event.pathParameters,
1723
queryStringParameters: event.queryStringParameters,
1824
});
19-
20-
// Start timeout timer
21-
timeoutTimer = setTimeout(() => {
22-
timeoutTimer && flush(new Error("Lambda will timeout in 100 ms"));
23-
}, context.getRemainingTimeInMillis() - 100);
24-
}
25-
26-
export function end() {
27-
// Clear timeout timer
28-
clearTimeout(timeoutTimer);
29-
timeoutTimer = null;
3025
}
3126

3227
export function flush(e) {
3328
logs.forEach(({ date, string }) => console.debug(date, string));
3429
console.error(e);
3530
}
36-
37-
export default function debug() {
38-
logs.push({
39-
date: new Date(),
40-
string: util.format.apply(null, arguments),
41-
});
42-
}

0 commit comments

Comments
 (0)