diff --git a/README.md b/README.md index 3ae59a3..6352161 100644 --- a/README.md +++ b/README.md @@ -385,7 +385,7 @@ The `REQUEST` object contains a parsed and normalized request from API Gateway. - `app`: A reference to an instance of the app - `version`: The version set at initialization - `id`: The awsRequestId from the Lambda `context` -- `interface`: The interface being used to access Lambda (either `apigateway` or `alb`) +- `interface`: The interface being used to access Lambda (`apigateway`,`alb`, or `edge`) - `params`: Dynamic path parameters parsed from the path (see [path parameters](#path-parameters)) - `method`: The HTTP method of the request - `path`: The path passed in by the request including the `base` and any `prefix` assigned to routes @@ -850,6 +850,7 @@ Logs are generated using Lambda API's standard JSON format. The log format can b "remaining": 2000, // remaining milliseconds until function timeout "function": "my-function-v1", // function name "memory": 2048, // allocated function memory + "int": "apigateway", // interface used to access the Lambda function "sample": true // is generated during sampling request? } ``` diff --git a/lib/logger.js b/lib/logger.js index 3dec9a1..344cbf9 100644 --- a/lib/logger.js +++ b/lib/logger.js @@ -107,6 +107,7 @@ exports.config = (config,levels) => { method: req.method, [messageKey]: msg, timer: timer(req._start), + int: req.interface, sample: req._sample ? true : undefined }, serializers.main(req), diff --git a/test/log.js b/test/log.js index 8e747df..4aa82d5 100644 --- a/test/log.js +++ b/test/log.js @@ -241,6 +241,7 @@ describe('Logging Tests:', function() { expect(_log[0]).to.have.property('remaining') expect(_log[0]).to.have.property('function') expect(_log[0]).to.have.property('memory') + expect(_log[0]).to.have.property('int') // access log expect(_log[4]).to.have.property('coldStart') expect(_log[4]).to.have.property('statusCode') @@ -278,6 +279,7 @@ describe('Logging Tests:', function() { expect(_log[0]).to.have.property('remaining') expect(_log[0]).to.have.property('function') expect(_log[0]).to.have.property('memory') + expect(_log[0]).to.have.property('int') // access log expect(_log[4]).to.have.property('coldStart') expect(_log[4]).to.have.property('statusCode') @@ -331,6 +333,7 @@ describe('Logging Tests:', function() { expect(_log[0]).to.have.property('remaining') expect(_log[0]).to.have.property('function') expect(_log[0]).to.have.property('memory') + expect(_log[0]).to.have.property('int') // access log expect(_log[5]).to.have.property('coldStart') expect(_log[5]).to.have.property('statusCode') @@ -384,6 +387,7 @@ describe('Logging Tests:', function() { expect(_log[0]).to.have.property('remaining') expect(_log[0]).to.have.property('function') expect(_log[0]).to.have.property('memory') + expect(_log[0]).to.have.property('int') // access log expect(_log[1]).to.have.property('coldStart') expect(_log[1]).to.have.property('statusCode') @@ -422,6 +426,7 @@ describe('Logging Tests:', function() { expect(_log[0]).to.have.property('remaining') expect(_log[0]).to.have.property('function') expect(_log[0]).to.have.property('memory') + expect(_log[0]).to.have.property('int') // access log expect(_log[1]).to.have.property('coldStart') expect(_log[1]).to.have.property('statusCode') @@ -458,6 +463,7 @@ describe('Logging Tests:', function() { expect(_log[0]).to.have.property('remaining') expect(_log[0]).to.have.property('function') expect(_log[0]).to.have.property('memory') + expect(_log[0]).to.have.property('int') // access log expect(_log[1]).to.have.property('coldStart') expect(_log[1]).to.have.property('statusCode') @@ -495,6 +501,7 @@ describe('Logging Tests:', function() { expect(_log[0]).to.have.property('remaining') expect(_log[0]).to.have.property('function') expect(_log[0]).to.have.property('memory') + expect(_log[0]).to.have.property('int') // access log expect(_log[1]).to.have.property('coldStart') expect(_log[1]).to.have.property('statusCode') @@ -533,6 +540,7 @@ describe('Logging Tests:', function() { expect(_log[0]).to.have.property('remaining') expect(_log[0]).to.have.property('function') expect(_log[0]).to.have.property('memory') + expect(_log[0]).to.have.property('int') // access log expect(_log[1]).to.have.property('coldStart') expect(_log[1]).to.have.property('statusCode') @@ -577,6 +585,7 @@ describe('Logging Tests:', function() { expect(_log[0]).to.have.property('remaining') expect(_log[0]).to.have.property('function') expect(_log[0]).to.have.property('memory') + expect(_log[0]).to.have.property('int') expect(_log[0]).to.have.property('coldStart') expect(_log[0]).to.have.property('path') expect(_log[0]).to.have.property('ip') @@ -593,6 +602,7 @@ describe('Logging Tests:', function() { expect(_log[1]).to.have.property('remaining') expect(_log[1]).to.have.property('function') expect(_log[1]).to.have.property('memory') + expect(_log[0]).to.have.property('int') expect(_log[1]).to.have.property('coldStart') expect(_log[1]).to.have.property('path') expect(_log[1]).to.have.property('ip') @@ -627,6 +637,7 @@ describe('Logging Tests:', function() { expect(_log[0]).to.have.property('remaining') expect(_log[0]).to.have.property('function') expect(_log[0]).to.have.property('memory') + expect(_log[0]).to.have.property('int') // these should NOT exist expect(_log[0]).to.not.have.property('coldStart') expect(_log[0]).to.not.have.property('statusCode') @@ -664,6 +675,7 @@ describe('Logging Tests:', function() { expect(_log[0].context).to.have.property('remaining') expect(_log[0].context).to.have.property('function') expect(_log[0].context).to.have.property('memory') + expect(_log[0]).to.have.property('int') expect(_log[0]).to.have.property('custom') expect(_log[0].custom).to.have.property('customMsg') // access log @@ -702,6 +714,7 @@ describe('Logging Tests:', function() { expect(_log[0]).to.have.property('remaining') expect(_log[0]).to.have.property('function') expect(_log[0]).to.have.property('memory') + expect(_log[0]).to.have.property('int') expect(_log[0]).to.have.property('path') expect(_log[0]).to.have.property('ip') expect(_log[0]).to.have.property('ua') @@ -752,6 +765,7 @@ describe('Logging Tests:', function() { expect(_log[0]).to.have.property('timer') expect(_log[0]).to.have.property('remaining') expect(_log[0]).to.have.property('function') + expect(_log[0]).to.have.property('int') // access log expect(_log[3]).to.have.property('time') expect(_log[3]).to.have.property('id') @@ -793,6 +807,7 @@ describe('Logging Tests:', function() { expect(_log[0]).to.have.property('msg') expect(_log[0]).to.have.property('timer') expect(_log[0]).to.have.property('remaining') + expect(_log[0]).to.have.property('int') expect(_log[0]).to.have.property('function') expect(_log[0]).to.have.property('TEST_CUSTOM') expect(_log[0]).to.have.property('TEST_CONTEXT') @@ -839,6 +854,7 @@ describe('Logging Tests:', function() { expect(_log[0]).to.have.property('msg') expect(_log[0]).to.have.property('timer') expect(_log[0]).to.have.property('remaining') + expect(_log[0]).to.have.property('int') expect(_log[0]).to.have.property('function') expect(_log[0]).to.have.property('custom') // access log @@ -932,6 +948,7 @@ describe('Logging Tests:', function() { expect(_log[0]).to.have.property('remaining') expect(_log[0]).to.have.property('function') expect(_log[0]).to.have.property('memory') + expect(_log[0]).to.have.property('int') expect(_log[0]).to.have.property('stack') expect(_log[1]).to.have.property('time')