-
Notifications
You must be signed in to change notification settings - Fork 154
Bug: Exception instead of warning when log level doesn't match AWS log level #2269
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
Comments
Thanks for opening your first issue here! We'll come back to you as soon as we can. |
Hi @deffer, thank you so much for opening this issue. I was able to reproduce the behavior you described and identify a gap in our tests. I'll be working on a fix and will open a PR as soon as I have it, together with some new tests. |
I have opened a PR that should fix the issue. Instead of swapping the order of the methods during the setup phase I have modified the init logic so that the order of these actions shouldn't matter. I have also added a test case that matches the "steps to reproduce" indicated above. |
This issue is now closed. Please be mindful that future comments 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. |
This is now released under v2.0.4 version! |
Expected Behaviour
Expect a following warning when the Application log level of AWS Lambda configuration is set to INFO while powertools level is set to DEBUG (via
logLevel
attribute of the ConstructorOptions)Current log level (%s) does not match AWS Lambda Advanced Logging Controls minimum log level (%s). This can lead to data loss, consider adjusting them.
Current Behaviour
Lambda is failing with the following error:
Code snippet
Use the following constructor options in the Lambda, while
Application log level
of the Lambda Logging configuration is set to INFO (along withLog Format
set to JSON).Instantiate the logger outside of the handler function:
Steps to Reproduce
Log Format
set to JSON andApplication log level
to INFOPossible Solution
In the
private setOptions(...)
method of the Logger, change the order of the initialization of initiaLogLevel and the logFormatter to make sure logFormatter is initialized before invokingthis.setInitialLogLevel(logLevel);
Reason:
The Logger's method
awsLogLevelShortCircuit
, which is invoked during the construction of the Logger with options, attempts to log a warning about mismatched log levels usingthis.warn()
. Thewarn()
method relies on thelogFormatter
been set, which has not happened yet.Powertools for AWS Lambda (TypeScript) version
latest
AWS Lambda function runtime
20.x
Packaging format used
npm
Execution logs
No response
The text was updated successfully, but these errors were encountered: