Skip to content

Feature request: logEvent method for manual usage #1006

Closed
@dreamorosi

Description

@dreamorosi

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 the injectLambdaContext 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

Related issues, RFCs

#1004

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature-requestThis item refers to a feature request for an existing or new utilitygood-first-issueSomething that is suitable for those who want to start contributingloggerThis item relates to the Logger UtilityrejectedThis is something we will not be working on. At least, not in the measurable future

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions