-
Notifications
You must be signed in to change notification settings - Fork 4k
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
fix(lambda): validate logLevel with logFormat for advanced logging #28045
fix(lambda): validate logLevel with logFormat for advanced logging #28045
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks 👍
Just a small adjustment on the message in my opinion.
Also, can you please add a note here on this requirement?
@@ -1077,6 +1077,10 @@ export class Function extends FunctionBase { | |||
* function and undefined if not. | |||
*/ | |||
private getLoggingConfig(props: FunctionProps): CfnFunction.LoggingConfigProperty | undefined { | |||
if ((props.applicationLogLevel || props.systemLogLevel) && props.logFormat !== LogFormat.JSON) { | |||
throw new Error('ApplicationLogLevel and SystemLogLevel cannot be specified without LogFormat being set to JSON.'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
throw new Error('ApplicationLogLevel and SystemLogLevel cannot be specified without LogFormat being set to JSON.'); | |
throw new Error(`To use ApplicationLogLevel and/or SystemLogLevel you must set LogFormat to '${LogFormat.JSON}', got '${props.logFormat}'.`); |
Message formatting.
Thanks! I changed it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution!
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
@Mergifyio update |
❌ Mergify doesn't have permission to updateFor security reasons, Mergify can't update this pull request. Try updating locally. |
Pull request has been modified.
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The pull request linter has failed. See the aws-cdk-automation comment below for failure reasons. If you believe this pull request should receive an exemption, please comment and provide a justification.
A comment requesting an exemption should contain the text Exemption Request
. Additionally, if clarification is needed add Clarification Request
to a comment.
The pull request linter fails with the following errors:
PRs must pass status checks before we can provide a meaningful review. If you would like to request an exemption from the status checks or clarification on feedback, please leave a comment on this PR containing |
This PR adds to validate whether
applicationLogLevel
andsystemLogLevel
have a JSONlogFormat
for advanced logging.The doc states the following:
https://docs.aws.amazon.com/lambda/latest/dg/monitoring-cloudwatchlogs.html#monitoring-cloudwatchlogs-advanced
If you specify
systemLogLevel
orapplicationLogLevel
withoutLogFormat.JSON
like the following code, an error occurred in a CFn event:This validation allows the error to be caught at the synth phase.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license