Skip to content

Commit

Permalink
Add validation
Browse files Browse the repository at this point in the history
  • Loading branch information
tomoish committed Dec 11, 2023
1 parent 7110b67 commit 8bfd2d6
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/aws-cdk-lib/aws-lambda/lib/function.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1085,6 +1085,9 @@ export class Function extends FunctionBase {
* function and undefined if not.
*/
private getLoggingConfig(props: FunctionProps): CfnFunction.LoggingConfigProperty | undefined {
if (props.logFormat !== undefined && !Object.values(LogFormat).includes(props.logFormat as LogFormat)) {
throw new TypeError(`'${props.logFormat}' is not a legal LogFormat type.`);
}
if ((props.applicationLogLevel || props.systemLogLevel) && props.logFormat !== LogFormat.JSON) {
throw new Error(`To use ApplicationLogLevel and/or SystemLogLevel you must set LogFormat to '${LogFormat.JSON}', got '${props.logFormat}'.`);
}
Expand Down

0 comments on commit 8bfd2d6

Please sign in to comment.