@@ -28,8 +28,6 @@ const consoleSpy = {
2828describe ( 'Class: Logger' , ( ) => {
2929
3030 beforeEach ( ( ) => {
31- Logger . setColdStartValue ( undefined ) ;
32- Logger . setColdStartEvaluatedValue ( false ) ;
3331 consoleSpy [ 'debug' ] . mockClear ( ) ;
3432 consoleSpy [ 'info' ] . mockClear ( ) ;
3533 consoleSpy [ 'warn' ] . mockClear ( ) ;
@@ -462,6 +460,7 @@ describe('Class: Logger', () => {
462460
463461 // Assess
464462 expect ( logger ) . toEqual ( {
463+ coldStart : false , // This is now false because the `coldStart` attribute has been already accessed once by the `addContext` method
465464 customConfigService : undefined ,
466465 envVarsService : expect . any ( EnvironmentVariablesService ) ,
467466 logFormatter : expect . any ( PowertoolLogFormatter ) ,
@@ -525,79 +524,6 @@ describe('Class: Logger', () => {
525524 } ) ;
526525 } ) ;
527526
528- describe ( 'Method: createChild' , ( ) => {
529-
530- test ( 'when called, creates a distinct clone of the original logger instance' , ( ) => {
531-
532- // Prepare
533- const logger = new Logger ( ) ;
534-
535- // Act
536- const childLogger = logger . createChild ( {
537- logLevel : 'ERROR' ,
538- } ) ;
539-
540- // Assess
541- expect ( logger ) . toEqual ( expect . objectContaining ( {
542- logLevel : 'DEBUG' ,
543- } ) ) ;
544- expect ( childLogger ) . toBeInstanceOf ( Logger ) ;
545- expect ( childLogger ) . toEqual ( expect . objectContaining ( {
546- logLevel : 'ERROR' ,
547- } ) ) ;
548- } ) ;
549-
550- } ) ;
551-
552- describe ( 'Method: evaluateColdStartOnce' , ( ) => {
553-
554- test ( 'when called during the first invocation (cold start), it populates the logger\'s PowertoolLogData object with coldstart set to true' , ( ) => {
555-
556- // Prepare
557- // This value is undefined at the beginning of the first invocation
558- Logger . setColdStartValue ( undefined ) ;
559-
560- // Act
561- Logger . evaluateColdStartOnce ( ) ;
562- Logger . evaluateColdStartOnce ( ) ;
563- Logger . evaluateColdStartOnce ( ) ;
564-
565- // Assess
566- expect ( Logger . getColdStartValue ( ) ) . toEqual ( true ) ;
567- } ) ;
568-
569- test ( 'when called during the SECOND invocation (warm start), it populates the logger\'s PowertoolLogData object with coldstart set to false' , ( ) => {
570-
571- // Prepare
572- // This value is set to true at the beginning of the second invocation
573- Logger . setColdStartValue ( true ) ;
574-
575- // Act
576- Logger . evaluateColdStartOnce ( ) ;
577- Logger . evaluateColdStartOnce ( ) ;
578- Logger . evaluateColdStartOnce ( ) ;
579-
580- // Assess
581- expect ( Logger . getColdStartValue ( ) ) . toEqual ( false ) ;
582- } ) ;
583-
584- test ( 'when called during the THIRD invocation (warm start), it populates the logger\'s PowertoolLogData object with coldstart set to false' , ( ) => {
585-
586- // Prepare
587- // This value is set to false at the beginning of the third invocation
588- Logger . setColdStartValue ( false ) ;
589-
590- // Act
591- Logger . evaluateColdStartOnce ( ) ;
592- Logger . evaluateColdStartOnce ( ) ;
593- Logger . evaluateColdStartOnce ( ) ;
594-
595- // Assess
596- expect ( Logger . getColdStartValue ( ) ) . toEqual ( false ) ;
597- } ) ;
598-
599- } ) ;
600-
601527 describe ( 'Method: injectLambdaContext' , ( ) => {
602528
603529 beforeEach ( ( ) => {
@@ -736,29 +662,6 @@ describe('Class: Logger', () => {
736662
737663 } ) ;
738664
739- describe ( 'Method: setColdStartValue' , ( ) => {
740-
741- test ( 'when called, it sets the value of the static variable coldStart in the same file' , async ( ) => {
742-
743- // Act
744- Logger . setColdStartValue ( undefined ) ;
745- const undefinedValue = Logger . getColdStartValue ( ) ;
746-
747- Logger . setColdStartValue ( true ) ;
748- const trueValue = Logger . getColdStartValue ( ) ;
749-
750- Logger . setColdStartValue ( false ) ;
751- const falseValue = Logger . getColdStartValue ( ) ;
752-
753- // Assess
754- expect ( undefinedValue ) . toBe ( undefined ) ;
755- expect ( trueValue ) . toBe ( true ) ;
756- expect ( falseValue ) . toBe ( false ) ;
757-
758- } ) ;
759-
760- } ) ;
761-
762665 describe ( 'Method: refreshSampleRateCalculation' , ( ) => {
763666
764667 test ( 'when called, it recalculates whether the current Lambda invocation\'s logs will be printed or not' , ( ) => {
@@ -815,6 +718,7 @@ describe('Class: Logger', () => {
815718 expect ( parentLogger === childLoggerWithErrorLogLevel ) . toBe ( false ) ;
816719
817720 expect ( parentLogger ) . toEqual ( {
721+ coldStart : true ,
818722 customConfigService : undefined ,
819723 envVarsService : expect . any ( EnvironmentVariablesService ) ,
820724 logFormatter : expect . any ( PowertoolLogFormatter ) ,
@@ -837,6 +741,7 @@ describe('Class: Logger', () => {
837741 } ) ;
838742
839743 expect ( childLoggerWithPermanentAttributes ) . toEqual ( {
744+ coldStart : true ,
840745 customConfigService : undefined ,
841746 envVarsService : expect . any ( EnvironmentVariablesService ) ,
842747 logFormatter : expect . any ( PowertoolLogFormatter ) ,
@@ -861,6 +766,7 @@ describe('Class: Logger', () => {
861766 } ) ;
862767
863768 expect ( childLoggerWithSampleRateEnabled ) . toEqual ( {
769+ coldStart : true ,
864770 customConfigService : undefined ,
865771 envVarsService : expect . any ( EnvironmentVariablesService ) ,
866772 logFormatter : expect . any ( PowertoolLogFormatter ) ,
@@ -883,6 +789,7 @@ describe('Class: Logger', () => {
883789 } ) ;
884790
885791 expect ( childLoggerWithErrorLogLevel ) . toEqual ( {
792+ coldStart : true ,
886793 customConfigService : undefined ,
887794 envVarsService : expect . any ( EnvironmentVariablesService ) ,
888795 logFormatter : expect . any ( PowertoolLogFormatter ) ,
0 commit comments