@@ -117,7 +117,7 @@ class Logger extends Utility implements LoggerInterface {
117117 /**
118118 * Custom config service instance used to configure the logger.
119119 */
120- private customConfigService ?: ConfigServiceInterface ;
120+ private readonly customConfigService ?: ConfigServiceInterface ;
121121 /**
122122 * Whether to print the Lambda invocation event in the logs.
123123 */
@@ -149,7 +149,7 @@ class Logger extends Utility implements LoggerInterface {
149149 /**
150150 * Standard attributes managed by Powertools that will be logged in all log items.
151151 */
152- private powertoolsLogData : PowertoolsLogData = < PowertoolsLogData > {
152+ private readonly powertoolsLogData : PowertoolsLogData = < PowertoolsLogData > {
153153 sampleRateValue : 0 ,
154154 } ;
155155 /**
@@ -169,14 +169,14 @@ class Logger extends Utility implements LoggerInterface {
169169 /**
170170 * Flag used to determine if the logger is initialized.
171171 */
172- #isInitialized = false ;
172+ readonly #isInitialized: boolean = false ;
173173 /**
174174 * Map used to hold the list of keys and their type.
175175 *
176176 * Because keys of different types can be overwritten, we keep a list of keys that were added and their last
177177 * type. We then use this map at log preparation time to pick the last one.
178178 */
179- #keys: Map < string , 'temp' | 'persistent' > = new Map ( ) ;
179+ readonly #keys: Map < string , 'temp' | 'persistent' > = new Map ( ) ;
180180 /**
181181 * This is the initial log leval as set during the initialization of the logger.
182182 *
@@ -263,7 +263,9 @@ class Logger extends Utility implements LoggerInterface {
263263 public constructor ( options : ConstructorOptions = { } ) {
264264 super ( ) ;
265265 const { customConfigService, ...rest } = options ;
266- this . setCustomConfigService ( customConfigService ) ;
266+ this . customConfigService = customConfigService
267+ ? customConfigService
268+ : undefined ;
267269 // all logs are buffered until the logger is initialized
268270 this . setOptions ( rest ) ;
269271 this . #isInitialized = true ;
@@ -1135,20 +1137,6 @@ class Logger extends Utility implements LoggerInterface {
11351137 } ;
11361138 }
11371139
1138- /**
1139- * Set the Logger's customer config service instance, which will be used
1140- * to fetch environment variables.
1141- *
1142- * @param customConfigService - The custom config service
1143- */
1144- private setCustomConfigService (
1145- customConfigService ?: ConfigServiceInterface
1146- ) : void {
1147- this . customConfigService = customConfigService
1148- ? customConfigService
1149- : undefined ;
1150- }
1151-
11521140 /**
11531141 * Set the initial Logger log level based on the following order:
11541142 * 1. If a log level is set using AWS Lambda Advanced Logging Controls, it sets it.
@@ -1199,8 +1187,6 @@ class Logger extends Utility implements LoggerInterface {
11991187 if ( this . isValidLogLevel ( logLevelValue ) ) {
12001188 this . logLevel = LogLevelThreshold [ logLevelValue ] ;
12011189 this . #initialLogLevel = this . logLevel ;
1202-
1203- return ;
12041190 }
12051191 }
12061192
0 commit comments