Skip to content

Docs: remove logEvent parameter from Logger constructor setting #1814

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
bestickley opened this issue Dec 8, 2023 · 6 comments · Fixed by #1821
Closed

Docs: remove logEvent parameter from Logger constructor setting #1814

bestickley opened this issue Dec 8, 2023 · 6 comments · Fixed by #1821
Assignees
Labels
completed This item is complete and has been merged/shipped documentation Improvements or additions to documentation logger This item relates to the Logger Utility

Comments

@bestickley
Copy link

Expected Behaviour

The docs state that Logger's constructor accepts a logEvent parameter to control whether or not logger prints event. But when I try to do this I get an error. See screenshot.
image

Current Behaviour

Cannot pass logEvent into constructor of Logger.

Code snippet

const logger = new Logger({
  logEvent: true, // ERROR: Object literal may only specify known properties, and 'logEvent' does not exist in 'ConstructorOptions'
});

Steps to Reproduce

  1. Reproduce code in code snippet above.
  2. See error.

Possible Solution

No response

Powertools for AWS Lambda (TypeScript) version

latest

AWS Lambda function runtime

18.x

Packaging format used

npm

Execution logs

No response

@bestickley bestickley added triage This item has not been triaged by a maintainer, please wait bug Something isn't working labels Dec 8, 2023
@dreamorosi
Copy link
Contributor

Hi @bestickley, thank you for opening the issue.

The documentation is wrong and we'll use this issue to fix it.

The logEvent property should not be part of the constructor because even with enabled, it can only work when the Logger is used in conjunction with the injectLambdaContext Middy middleware or class method decorator.

This is because we can only log the event when the handler is wrapped by the decorator or middleware. If we allowed the setting in the constructor, this could make customers think that by simply enabling the option Logger will log the event, which is not the case.

We do have an environment variable, but that's mostly to disable the behavior without changing the code either in a dev environment or after deployment.

With this in mind I'm inclined to consider not a bug, not a feature request, but rather an action point to change the docs.

@dreamorosi dreamorosi added documentation Improvements or additions to documentation logger This item relates to the Logger Utility confirmed The scope is clear, ready for implementation and removed bug Something isn't working triage This item has not been triaged by a maintainer, please wait labels Dec 8, 2023
@am29d am29d self-assigned this Dec 18, 2023
@kaihendry
Copy link

I don't quite understand what the process is to log the incoming event.

Idea is to surface it easily, ideally in the AWS console for debugging.

Could that please be documented too?

@am29d
Copy link
Contributor

am29d commented Dec 18, 2023

I agree @kaihendry , we can add a small section specifically for logging events.

@dreamorosi dreamorosi changed the title Bug: Logger Constructor Missing logEvent Parameter Docs: remove logEvent parameter from Logger constructor setting Dec 19, 2023
@dreamorosi
Copy link
Contributor

Hi @kaihendry - we do have a section dedicated to this feature - which can be found here.

When enabled, the feature instructs the logger instance to emit one log at INFO level containing the payload of the event for that invocation. Given that this is a regular log, you'll be able to see it in the CloudWatch dashboard in all the same places where you already access logs (Log Groups, Tail, Insights, etc.).

Given that the Logger utility must have access to the function event for it to log it, the feature is available only when using the injectLambdaContext Middy middleware or @ injectLambdaContext class method decorator. This is also why - despite the inaccurate documentation - the setting is not available at the constructor level.

@am29d am29d moved this from Backlog to Working on it in Powertools for AWS Lambda (TypeScript) Dec 19, 2023
@am29d
Copy link
Contributor

am29d commented Dec 19, 2023

we do have a section dedicated to this feature - which can be found here.

I scanned the outline multiple times and missed it 😵‍💫

Copy link
Contributor

⚠️ COMMENT VISIBILITY WARNING ⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

@dreamorosi dreamorosi added completed This item is complete and has been merged/shipped and removed confirmed The scope is clear, ready for implementation labels Jan 26, 2024
@dreamorosi dreamorosi moved this from Coming soon to Shipped in Powertools for AWS Lambda (TypeScript) Jan 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
completed This item is complete and has been merged/shipped documentation Improvements or additions to documentation logger This item relates to the Logger Utility
Projects
Development

Successfully merging a pull request may close this issue.

4 participants