diff --git a/libs/debug-lib.js b/libs/debug-lib.js index 1b5ce0e..bb9d1f8 100644 --- a/libs/debug-lib.js +++ b/libs/debug-lib.js @@ -1,11 +1,17 @@ -import AWS from "aws-sdk"; import util from "util"; +import AWS from "aws-sdk"; + +let logs; // Log AWS SDK calls AWS.config.logger = { log: debug }; -let logs; -let timeoutTimer; +export default function debug() { + logs.push({ + date: new Date(), + string: util.format.apply(null, arguments), + }); +} export function init(event, context) { logs = []; @@ -16,27 +22,9 @@ export function init(event, context) { pathParameters: event.pathParameters, queryStringParameters: event.queryStringParameters, }); - - // Start timeout timer - timeoutTimer = setTimeout(() => { - timeoutTimer && flush(new Error("Lambda will timeout in 100 ms")); - }, context.getRemainingTimeInMillis() - 100); -} - -export function end() { - // Clear timeout timer - clearTimeout(timeoutTimer); - timeoutTimer = null; } export function flush(e) { logs.forEach(({ date, string }) => console.debug(date, string)); console.error(e); } - -export default function debug() { - logs.push({ - date: new Date(), - string: util.format.apply(null, arguments), - }); -}