Skip to content

Commit

Permalink
feat: log with powertools logger
Browse files Browse the repository at this point in the history
  • Loading branch information
theburningmonk committed May 22, 2019
1 parent 8db9a02 commit 7153b6d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
5 changes: 4 additions & 1 deletion middlewares/log_timeout_middleware.js
@@ -1,4 +1,5 @@
const Promise = require('bluebird')
const Log = require('@perform/lambda-powertools-logger')

module.exports = () => {
let isTimedOut = undefined
Expand All @@ -10,7 +11,9 @@ module.exports = () => {

Promise.delay(timeLeft - 10).then(() => {
if (isTimedOut !== false) {
console.log('function timed out')
const awsRequestId = handler.context.awsRequestId
const invocationEvent = JSON.stringify(handler.event)
Log.error('invocation timed out', { awsRequestId, invocationEvent })
}
})

Expand Down
13 changes: 13 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Expand Up @@ -19,6 +19,7 @@
},
"homepage": "https://github.com/theburningmonk/lambda-log-timeout-demo#readme",
"dependencies": {
"@perform/lambda-powertools-logger": "^1.1.7",
"bluebird": "^3.5.4",
"middy": "^0.27.0"
},
Expand Down

0 comments on commit 7153b6d

Please sign in to comment.