8000 close #88 by adding interface to logs · jthomerson/lambda-api@7d6c169 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7d6c169

Browse files
committed
close jeremydaly#88 by adding interface to logs
1 parent 96687cb commit 7d6c169

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ The `REQUEST` object contains a parsed and normalized request from API Gateway.
385385
- `app`: A reference to an instance of the app
386386
- `version`: The version set at initialization
387387
- `id`: The awsRequestId from the Lambda `context`
388-
- `interface`: The interface being used to access Lambda (either `apigateway` or `alb`)
388+
- `interface`: The interface being used to access Lambda (`apigateway`,`alb`, or `edge`)
389389
- `params`: Dynamic path parameters parsed from the path (see [path parameters](#path-parameters))
390390
- `method`: The HTTP method of the request
391391
- `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
850850
"remaining": 2000, // remaining milliseconds until function timeout
851851
"function": "my-function-v1", // function name
852852
"memory": 2048, // allocated function memory
853+
"int": "apigateway", // interface used to access the Lambda function
853854
"sample": true // is generated during sampling request?
854855
}
855856
```

lib/logger.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ exports.config = (config,levels) => {
107107
method: req.method,
108108
[messageKey]: msg,
109109
timer: timer(req._start),
110+
int: req.interface,
110111
sample: req._sample ? true : undefined
111112
},
112113
serializers.main(req),

test/log.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@ describe('Logging Tests:', function() {
241241
expect(_log[0]).to.have.property('remaining')
242242
expect(_log[0]).to.have.property('function')
243243
expect(_log[0]).to.have.property('memory')
244+
expect(_log[0]).to.have.property('int')
244245
// access log
245246
expect(_log[4]).to.have.property('coldStart')
246247
expect(_log[4]).to.have.property('statusCode')
@@ -278,6 +279,7 @@ describe('Logging Tests:', function() {
278279
expect(_log[0]).to.have.property('remaining')
279280
expect(_log[0]).to.have.property('function')
280281
expect(_log[0]).to.have.property('memory')
282+
expect(_log[0]).to.have.property('int')
281283
// access log
282284
expect(_log[4]).to.have.property('coldStart')
283285
expect(_log[4]).to.have.property('statusCode')
@@ -331,6 +333,7 @@ describe('Logging Tests:', function() {
331333
expect(_log[0]).to.have.property('remaining')
332334
expect(_log[0]).to.have.property('function')
333335
expect(_log[0]).to.have.property('memory')
336+
expect(_log[0]).to.have.property('int')
334337
// access log
335338
expect(_log[5]).to.have.property('coldStart')
336339
expect(_log[5]).to.have.property('statusCode')
@@ -384,6 +387,7 @@ describe('Logging Tests:', function() {
384387
expect(_log[0]).to.have.property('remaining')
385388
expect(_log[0]).to.have.property('function')
386389
expect(_log[0]).to.have.property('memory')
390+
expect(_log[0]).to.have.property('int')
387391
// access log
388392
expect(_log[1]).to.have.property('coldStart')
389393
expect(_log[1]).to.have.property('statusCode')
@@ -422,6 +426,7 @@ describe('Logging Tests:', function() {
422426
expect(_log[0]).to.have.property('remaining')
423427
expect(_log[0]).to.have.property('function')
424428
expect(_log[0]).to.have.property('memory')
429+
expect(_log[0]).to.have.property('int')
425430
// access log
426431
expect(_log[1]).to.have.property('coldStart')
427432
expect(_log[1]).to.have.property('statusCode')
@@ -458,6 +463,7 @@ describe('Logging Tests:', function() {
458463
expect(_log[0]).to.have.property('remaining')
459464
expect(_log[0]).to.have.property('function')
460465
expect(_log[0]).to.have.property('memory')
466+
expect(_log[0]).to.have.property('int')
461467
// access log
462468
expect(_log[1]).to.have.property('coldStart')
463469
expect(_log[1]).to.have.property('statusCode')
@@ -495,6 +501,7 @@ describe('Logging Tests:', function() {
495501
expect(_log[0]).to.have.property('remaining')
496502
expect(_log[0]).to.have.property('function')
497503
expect(_log[0]).to.have.property('memory')
504+
expect(_log[0]).to.have.property('int')
498505
// access log
499506
expect(_log[1]).to.have.property('coldStart')
500507
expect(_log[1]).to.have.property('statusCode')
@@ -533,6 +540,7 @@ describe('Logging Tests:', function() {
533540
expect(_log[0]).to.have.property('remaining')
534541
expect(_log[0]).to.have.property('function')
535542
expect(_log[0]).to.have.property('memory')
543+
expect(_log[0]).to.have.property('int')
536544
// access log
537545
expect(_log[1]).to.have.property('coldStart')
538546
expect(_log[1]).to.have.property('statusCode')
@@ -577,6 +585,7 @@ describe('Logging Tests:', function() {
577585
expect(_log[0]).to.have.property('remaining')
578586
expect(_log[0]).to.have.property('function')
579587
expect(_log[0]).to.have.property('memory')
588+
expect(_log[0]).to.have.property('int')
580589
expect(_log[0]).to.have.property('coldStart')
581590
expect(_log[0]).to.have.property('path')
582591
expect(_log[0]).to.have.property('ip')
@@ -593,6 +602,7 @@ describe('Logging Tests:', function() {
593602
expect(_log[1]).to.have.property('remaining')
594603
expect(_log[1]).to.have.property('function')
595604
expect(_log[1]).to.have.property('memory')
605+
expect(_log[0]).to.have.property('int')
596606
expect(_log[1]).to.have.property('coldStart')
597607
expect(_log[1]).to.have.property('path')
598608
expect(_log[1]).to.have.property('ip')
@@ -627,6 +637,7 @@ describe('Logging Tests:', function() {
627637
expect(_log[0]).to.have.property('remaining')
628638
expect(_log[0]).to.have.property('function')
629639
expect(_log[0]).to.have.property('memory')
640+
expect(_log[0]).to.have.property('int')
630641
// these should NOT exist
631642
expect(_log[0]).to.not.have.property('coldStart')
632643
expect(_log[0]).to.not.have.property('statusCode')
@@ -664,6 +675,7 @@ describe('Logging Tests:', function() {
664675
expect(_log[0].context).to.have.property('remaining')
665676
expect(_log[0].context).to.have.property('function')
666677
expect(_log[0].context).to.have.property('memory')
678+
expect(_log[0]).to.have.property('int')
667679
expect(_log[0]).to.have.property('custom')
668680
expect(_log[0].custom).to.have.property('customMsg')
669681
// access log
@@ -702,6 +714,7 @@ describe('Logging Tests:', function() {
702714
expect(_log[0]).to.have.property('remaining')
703715
expect(_log[0]).to.have.property('function')
704716
expect(_log[0]).to.have.property('memory')
717+
expect(_log[0]).to.have.property('int')
705718
expect(_log[0]).to.have.property('path')
706719
expect(_log[0]).to.have.property('ip')
707720
expect(_log[0]).to.have.property('ua')
@@ -752,6 +765,7 @@ describe('Logging Tests:', function() {
752765
expect(_log[0]).to.have.property('timer')
753766
expect(_log[0]).to.have.property('remaining')
754767
expect(_log[0]).to.have.property('function')
768+
expect(_log[0]).to.have.property('int')
755769
// access log
756770
expect(_log[3]).to.have.property('time')
757771
expect(_log[3]).to.have.property('id')
@@ -793,6 +807,7 @@ describe('Logging Tests:', function() {
793807
expect(_log[0]).to.have.property('msg')
794808
expect(_log[0]).to.have.property('timer')
795809
expect(_log[0]).to.have.property('remaining')
810+
expect(_log[0]).to.have.property('int')
796811
expect(_log[0]).to.have.property('function')
797812
expect(_log[0]).to.have.property('TEST_CUSTOM')
798813
expect(_log[0]).to.have.property('TEST_CONTEXT')
@@ -839,6 +854,7 @@ describe('Logging Tests:', function() {
839854
expect(_log[0]).to.have.property('msg')
840855
expect(_log[0]).to.have.property('timer')
841856
expect(_log[0]).to.have.property('remaining')
857+
expect(_log[0]).to.have.property('int')
842858
expect(_log[0]).to.have.property('function')
843859
expect(_log[0]).to.have.property('custom')
844860
// access log
@@ -932,6 +948,7 @@ describe('Logging Tests:', function() {
932948
expect(_log[0]).to.have.property('remaining')
933949
expect(_log[0]).to.have.property('function')
934950
expect(_log[0]).to.have.property('memory')
951+
expect(_log[0]).to.have.property('int')
935952
expect(_log[0]).to.have.property('stack')
936953

937954
expect(_log[1]).to.have.property('time')

0 commit comments

Comments
 (0)
0