"use strict";var _a;Object.defineProperty(exports,"__esModule",{value:!0}),exports.AwsLogDriver=exports.AwsLogDriverMode=void 0;const jsiiDeprecationWarnings=require("../../../.warnings.jsii.js"),JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti"),log_driver_1=require("./log-driver"),utils_1=require("./utils"),logs=require("../../../aws-logs"),core_1=require("../../../core");var AwsLogDriverMode;(function(AwsLogDriverMode2){AwsLogDriverMode2.BLOCKING="blocking",AwsLogDriverMode2.NON_BLOCKING="non-blocking"})(AwsLogDriverMode||(exports.AwsLogDriverMode=AwsLogDriverMode={}));class AwsLogDriver extends log_driver_1.LogDriver{constructor(props){super(),this.props=props;try{jsiiDeprecationWarnings.aws_cdk_lib_aws_ecs_AwsLogDriverProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,AwsLogDriver),error}if(props.logGroup&&props.logRetention)throw new Error("Cannot specify both `logGroup` and `logRetentionDays`.");if(props.maxBufferSize&&props.mode!==AwsLogDriverMode.NON_BLOCKING)throw new Error("Cannot specify `maxBufferSize` when the driver mode is blocking")}bind(scope,containerDefinition){try{jsiiDeprecationWarnings.aws_cdk_lib_aws_ecs_ContainerDefinition(containerDefinition)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.bind),error}this.logGroup=this.props.logGroup||new logs.LogGroup(scope,"LogGroup",{retention:this.props.logRetention||1/0});const maxBufferSize=this.props.maxBufferSize?`${this.props.maxBufferSize.toBytes({rounding:core_1.SizeRoundingBehavior.FLOOR})}b`:void 0;return this.logGroup.grantWrite(containerDefinition.taskDefinition.obtainExecutionRole()),{logDriver:"awslogs",options:(0,utils_1.removeEmpty)({"awslogs-group":this.logGroup.logGroupName,"awslogs-stream-prefix":this.props.streamPrefix,"awslogs-region":this.logGroup.env.region,"awslogs-datetime-format":this.props.datetimeFormat,"awslogs-multiline-pattern":this.props.multilinePattern,mode:this.props.mode,"max-buffer-size":maxBufferSize})}}}exports.AwsLogDriver=AwsLogDriver,_a=JSII_RTTI_SYMBOL_1,AwsLogDriver[_a]={fqn:"aws-cdk-lib.aws_ecs.AwsLogDriver",version:"2.96.1"};
