File tree Expand file tree Collapse file tree 2 files changed +33
-1
lines changed
packages/aws-cdk-lib/custom-resources Expand file tree Collapse file tree 2 files changed +33
-1
lines changed Original file line number Diff line number Diff line change @@ -324,7 +324,8 @@ export class Provider extends Construct implements ICustomResourceProvider {
324324 handler : `framework.${ entrypoint } ` ,
325325 timeout : FRAMEWORK_HANDLER_TIMEOUT ,
326326
327- logFormat : lambda . LogFormat . JSON ,
327+ // Using loggingFormat instead of deprecated logFormat which will be removed in the next major release
328+ loggingFormat : lambda . LoggingFormat . JSON ,
328329 applicationLogLevelV2 : loggingLevel ,
329330 // props.logRetention is deprecated, make sure we only set it if it is actually provided
330331 // otherwise jsii will print warnings even for users that don't use this directly
Original file line number Diff line number Diff line change @@ -365,6 +365,37 @@ test('Log level are set to FATAL by default', () => {
365365 } ) ;
366366} ) ;
367367
368+ test ( 'uses loggingFormat instead of deprecated logFormat' , ( ) => {
369+ // GIVEN
370+ // Spy on console.warn to check for deprecation warnings
371+ // eslint-disable-next-line no-console
372+ const warnSpy = jest . spyOn ( console , 'warn' ) . mockImplementation ( ( ) => { } ) ;
373+
374+ const stack = new Stack ( ) ;
375+ const handler = new lambda . Function ( stack , 'MyHandler' , {
376+ code : new lambda . InlineCode ( 'foo' ) ,
377+ handler : 'index.onEvent' ,
378+ runtime : lambda . Runtime . NODEJS_LATEST ,
379+ } ) ;
380+
381+ try {
382+ // WHEN
383+ new cr . Provider ( stack , 'MyProvider' , {
384+ onEventHandler : handler ,
385+ } ) ;
386+
387+ // THEN
388+ // Check that no deprecation warnings related to logFormat were emitted
389+ const deprecationWarnings = warnSpy . mock . calls
390+ . filter ( args => typeof args [ 0 ] === 'string' && args [ 0 ] . includes ( 'logFormat is deprecated' ) ) ;
391+
392+ expect ( deprecationWarnings . length ) . toBe ( 0 ) ;
393+ } finally {
394+ // Clean up
395+ warnSpy . mockRestore ( ) ;
396+ }
397+ } ) ;
398+
368399describe ( 'retry policy' , ( ) => {
369400 const stack = new Stack ( ) ;
370401
You can’t perform that action at this time.
0 commit comments