Skip to content

Commit 29a2444

Browse files
committed
feat(logger): add POWERTOOLS_DEV env var and method to get its value
1 parent 3584db1 commit 29a2444

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

packages/logger/src/config/ConfigServiceInterface.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@ interface ConfigServiceInterface {
2222
*/
2323
getCurrentEnvironment(): string
2424

25+
/**
26+
* It returns the value of the POWERTOOLS_DEV environment variable.
27+
*
28+
* @returns {boolean}
29+
*/
30+
getDevMode(): boolean
31+
2532
/**
2633
* It returns the value of the POWERTOOLS_LOGGER_LOG_EVENT environment variable.
2734
*

packages/logger/src/config/EnvironmentVariablesService.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class EnvironmentVariablesService extends CommonEnvironmentVariablesService impl
2020
// Reserved environment variables
2121
private awsRegionVariable = 'AWS_REGION';
2222
private currentEnvironmentVariable = 'ENVIRONMENT';
23+
private devModeVariable = 'POWERTOOLS_DEV';
2324
private functionNameVariable = 'AWS_LAMBDA_FUNCTION_NAME';
2425
private functionVersionVariable = 'AWS_LAMBDA_FUNCTION_VERSION';
2526
private logEventVariable = 'POWERTOOLS_LOGGER_LOG_EVENT';
@@ -45,6 +46,17 @@ class EnvironmentVariablesService extends CommonEnvironmentVariablesService impl
4546
return this.get(this.currentEnvironmentVariable);
4647
}
4748

49+
/**
50+
* It returns the value of the POWERTOOLS_DEV environment variable.
51+
*
52+
* @returns {boolean}
53+
*/
54+
public getDevMode(): boolean {
55+
const value = this.get(this.devModeVariable);
56+
57+
return value.toLowerCase() === 'true' || value === '1';
58+
}
59+
4860
/**
4961
* It returns the value of the AWS_LAMBDA_FUNCTION_MEMORY_SIZE environment variable.
5062
*

0 commit comments

Comments
 (0)