Skip to content

Commit 5ec2267

Browse files
committed
update parsers debugging to include original event in debug logs
1 parent 2745d98 commit 5ec2267

File tree

8 files changed

+20
-11
lines changed

8 files changed

+20
-11
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
44

55
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html)
66

7+
## [4.0.4]  (2020-09-06)
8+
9+
### Changed
10+
11+
- Better debug logging of events - include original and parsed messages instead of just parsed
12+
713
## [4.0.3]  (2020-09-06)
814

915
### Changed
@@ -279,6 +285,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/),
279285
- Update older libraries
280286
- Now publish from Git tags instead of master pushes
281287

288+
[4.0.2]: https://github.com/manwaring/lambda-wrapper/compare/v4.0.3...v4.0.4
289+
[4.0.3]: https://github.com/manwaring/lambda-wrapper/compare/v4.0.2...v4.0.3
282290
[4.0.2]: https://github.com/manwaring/lambda-wrapper/compare/v4.0.1...v4.0.2
283291
[4.0.1]: https://github.com/manwaring/lambda-wrapper/compare/v4.0.0...v4.0.1
284292
[4.0.0]: https://github.com/manwaring/lambda-wrapper/compare/v3.7.0...v4.0.0

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
<img src="https://flat.badgen.net/david/dep/manwaring/lambda-wrapper"></a>
2626
<a href="https://david-dm.org/manwaring/lambda-wrapper?type=dev">
2727
<img src="https://flat.badgen.net/david/dev/manwaring/lambda-wrapper/?label=dev+dependencies"></a>
28+
<img height="0" width="0" src="https://b7z7o7y5fi.execute-api.us-east-1.amazonaws.com/v1/readme/visits/github/manwaring/lambda-wrapper?style=flat-square">
2829
</p>
2930

3031
# AWS Lambda wrapper library
@@ -1311,6 +1312,3 @@ interface WrapperSignature<T> {
13111312
There is one [working example](examples) of how this package can be used in a simple 'hello world' serverless application:
13121313

13131314
1. [Using the Serverless Framework and TypeScript](examples/ts)
1314-
1315-
<img height="0" src="https://b7z7o7y5fi.execute-api.us-east-1.amazonaws.com/v1/readme/visits/github/manwaring/lambda-wrapper?style=flat-square">
1316-

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@manwaring/lambda-wrapper",
33
"description": "A lambda handler wrapper to abstract common functionality and provide useful defaults",
4-
"version": "4.0.3",
4+
"version": "4.0.4",
55
"scripts": {
66
"publish-please-dry-run": "publish-please --dry-run",
77
"publish-please": "publish-please",

src/api/v1/parser.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ export class Request {
1717
const body = new Body(event.body, headers).getParsedBody();
1818
const TEST_REQUEST_HEADER = process.env.TEST_REQUEST_HEADER || 'Test-Request';
1919
const testRequest = headers && headers[TEST_REQUEST_HEADER] ? JSON.parse(headers[TEST_REQUEST_HEADER]) : false;
20-
metrics.common({ body, websocket, path, query, auth, headers, testRequest });
21-
return { body, websocket, path, query, auth, headers, testRequest };
20+
const parsed = { body, websocket, path, query, auth, headers, testRequest };
21+
metrics.common(parsed, event);
22+
return parsed;
2223
}
2324

2425
private getAuth() {

src/api/v2-http/parser.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ export class Request {
1616
const body = new Body(event.body, headers).getParsedBody();
1717
const TEST_REQUEST_HEADER = process.env.TEST_REQUEST_HEADER || 'Test-Request';
1818
const testRequest = headers && headers[TEST_REQUEST_HEADER] ? JSON.parse(headers[TEST_REQUEST_HEADER]) : false;
19-
metrics.common({ body, path, query, auth, headers, testRequest });
20-
return { body, path, query, auth, headers, testRequest };
19+
const parsed = { body, path, query, auth, headers, testRequest };
20+
metrics.common(parsed, event);
21+
return parsed;
2122
}
2223

2324
private getAuth() {

src/common/metrics.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ import { logger } from './log';
33
export class Metrics {
44
constructor(private type: string) {}
55

6-
common(payload): void {
6+
common(parsed: any, original?: any): void {
77
const { REVISION, STAGE, AWS_REGION } = process.env;
8+
const payload = original ? { original, parsed } : parsed;
89
logger.debug(`Received ${this.type} event payload`, payload);
910
if (AWS_REGION) {
1011
logger.info('region', AWS_REGION);

src/sns/wrapper.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export function sns<T = any>(
1010
): (event: SNSEvent, context: Context, callback: Callback) => any {
1111
return function handler(event: SNSEvent, context: Context, callback: Callback) {
1212
const message = new SnsParser<T>(event).getMessage();
13-
metrics.common(message);
13+
metrics.common(message, event);
1414
return custom({ event, message, success, error });
1515
};
1616
}

0 commit comments

Comments
 (0)