Description
Description of the feature request
Problem statement
PR #1004 introduced a new behaviour in the Logger decorator and middleware that allows to emit a log entry that contains the handler's event
payload.
It would be great if this feature was available also for those users who don't use decorators or middy middleware.
In addition, a couple of changes related to this topic could be made in other sections:
- Since in the docs we call out that this method is for debugging only, I'd expect the log level to be DEBUG instead of INFO.
- In the
packages/logger/src/middy.ts
docstring of theinjectLambdaContext
middleware we should document the new flag/new behaviour so that it appears also in the API docs. - In the new sub-section of the docs where we show this method, it'd be nice to have a log excerpt. I was not sure which key the event would use in the JSON log (event duh).
Summary of the feature
Add public method like logger.logEvent(event);
, as well as the changes listed above.
Code examples
N/A
Benefits for you and the wider AWS community
Better DX for users who want log the handler's event parameter during development / debugging but are not using middleware nor decorator.
Describe alternatives you've considered
Logging the event directly logger.debug('event', { event });
The above is not admittedly that bad, I convene that this proposal is purely syntactic sugar.
Additional context
N/A