File tree Expand file tree Collapse file tree 1 file changed +9
-21
lines changed Expand file tree Collapse file tree 1 file changed +9
-21
lines changed Original file line number Diff line number Diff line change 1- import AWS from "aws-sdk" ;
21import util from "util" ;
2+ import AWS from "aws-sdk" ;
3+
4+ let logs ;
35
46// Log AWS SDK calls
57AWS . 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
1016export 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
3227export 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- }
You can’t perform that action at this time.
0 commit comments