@aws-lambda-powertools/logger
Advanced tools
Comparing version 2.0.0-alpha.2 to 2.0.0
@@ -15,3 +15,3 @@ import { ConfigServiceInterface } from '../types/ConfigServiceInterface.js'; | ||
* @see https://docs.aws.amazon.com/lambda/latest/dg/configuration-envvars.html#configuration-envvars-runtime | ||
* @see https://docs.powertools.aws.dev/lambda-typescript/latest/#environment-variables | ||
* @see https://docs.powertools.aws.dev/lambda/typescript/latest/#environment-variables | ||
*/ | ||
@@ -100,10 +100,4 @@ declare class EnvironmentVariablesService extends CommonEnvironmentVariablesService implements ConfigServiceInterface { | ||
getTimezone(): string; | ||
/** | ||
* It returns true if the POWERTOOLS_DEV environment variable is set to truthy value. | ||
* | ||
* @returns {boolean} | ||
*/ | ||
isDevMode(): boolean; | ||
} | ||
export { EnvironmentVariablesService }; | ||
//# sourceMappingURL=EnvironmentVariablesService.d.ts.map |
@@ -17,17 +17,20 @@ "use strict"; | ||
* @see https://docs.aws.amazon.com/lambda/latest/dg/configuration-envvars.html#configuration-envvars-runtime | ||
* @see https://docs.powertools.aws.dev/lambda-typescript/latest/#environment-variables | ||
* @see https://docs.powertools.aws.dev/lambda/typescript/latest/#environment-variables | ||
*/ | ||
class EnvironmentVariablesService extends commons_1.EnvironmentVariablesService { | ||
// Reserved environment variables | ||
awsLogLevelVariable = 'AWS_LAMBDA_LOG_LEVEL'; | ||
awsRegionVariable = 'AWS_REGION'; | ||
currentEnvironmentVariable = 'ENVIRONMENT'; | ||
functionNameVariable = 'AWS_LAMBDA_FUNCTION_NAME'; | ||
functionVersionVariable = 'AWS_LAMBDA_FUNCTION_VERSION'; | ||
logEventVariable = 'POWERTOOLS_LOGGER_LOG_EVENT'; | ||
logLevelVariable = 'POWERTOOLS_LOG_LEVEL'; | ||
logLevelVariableLegacy = 'LOG_LEVEL'; | ||
memoryLimitInMBVariable = 'AWS_LAMBDA_FUNCTION_MEMORY_SIZE'; | ||
sampleRateValueVariable = 'POWERTOOLS_LOGGER_SAMPLE_RATE'; | ||
tzVariable = 'TZ'; | ||
constructor() { | ||
super(...arguments); | ||
// Reserved environment variables | ||
this.awsLogLevelVariable = 'AWS_LAMBDA_LOG_LEVEL'; | ||
this.awsRegionVariable = 'AWS_REGION'; | ||
this.currentEnvironmentVariable = 'ENVIRONMENT'; | ||
this.functionNameVariable = 'AWS_LAMBDA_FUNCTION_NAME'; | ||
this.functionVersionVariable = 'AWS_LAMBDA_FUNCTION_VERSION'; | ||
this.logEventVariable = 'POWERTOOLS_LOGGER_LOG_EVENT'; | ||
this.logLevelVariable = 'POWERTOOLS_LOG_LEVEL'; | ||
this.logLevelVariableLegacy = 'LOG_LEVEL'; | ||
this.memoryLimitInMBVariable = 'AWS_LAMBDA_FUNCTION_MEMORY_SIZE'; | ||
this.sampleRateValueVariable = 'POWERTOOLS_LOGGER_SAMPLE_RATE'; | ||
this.tzVariable = 'TZ'; | ||
} | ||
/** | ||
@@ -130,12 +133,3 @@ * It returns the value of the `AWS_LAMBDA_LOG_LEVEL` environment variable. | ||
} | ||
/** | ||
* It returns true if the POWERTOOLS_DEV environment variable is set to truthy value. | ||
* | ||
* @returns {boolean} | ||
*/ | ||
isDevMode() { | ||
const value = this.get(this.devModeVariable); | ||
return this.isValueTrue(value); | ||
} | ||
} | ||
exports.EnvironmentVariablesService = EnvironmentVariablesService; |
@@ -5,2 +5,15 @@ "use strict"; | ||
/** | ||
* Typeguard to monkey patch Error to add a cause property. | ||
* | ||
* This is needed because the `cause` property is present in ES2022 or newer. | ||
* Since we want to be able to format errors in Node 16.x, we need to | ||
* add this property ourselves. We can remove this once we drop support | ||
* for Node 16.x. | ||
* | ||
* @see https://nodejs.org/api/errors.html#errors_error_cause | ||
*/ | ||
const isErrorWithCause = (error) => { | ||
return 'cause' in error; | ||
}; | ||
/** | ||
* This class defines and implements common methods for the formatting of log attributes. | ||
@@ -13,7 +26,2 @@ * | ||
class LogFormatter { | ||
/** | ||
* EnvironmentVariablesService instance. | ||
* If set, it allows to access environment variables. | ||
*/ | ||
envVarsService; | ||
constructor(options) { | ||
@@ -34,5 +42,7 @@ this.envVarsService = options?.envVarsService; | ||
stack: error.stack, | ||
cause: error.cause instanceof Error | ||
? this.formatError(error.cause) | ||
: error.cause, | ||
cause: isErrorWithCause(error) | ||
? error.cause instanceof Error | ||
? this.formatError(error.cause) | ||
: error.cause | ||
: undefined, | ||
}; | ||
@@ -39,0 +49,0 @@ } |
@@ -9,4 +9,4 @@ "use strict"; | ||
class LogItem { | ||
attributes = {}; | ||
constructor(params) { | ||
this.attributes = {}; | ||
// Add attributes in the log item in this order: | ||
@@ -13,0 +13,0 @@ // - Base attributes supported by the Powertool by default |
@@ -18,3 +18,3 @@ import { Utility } from '@aws-lambda-powertools/commons'; | ||
* | ||
* For more usage examples, see [our documentation](https://docs.powertools.aws.dev/lambda-typescript/latest/core/logger/). | ||
* For more usage examples, see [our documentation](https://docs.powertools.aws.dev/lambda/typescript/latest/core/logger/). | ||
* | ||
@@ -38,3 +38,4 @@ * ### Basic usage | ||
* ```typescript | ||
* import { Logger, injectLambdaContext } from '@aws-lambda-powertools/logger'; | ||
* import { Logger } from '@aws-lambda-powertools/logger'; | ||
* import { injectLambdaContext } from '@aws-lambda-powertools/logger/middleware'; | ||
* import middy from '@middy/core'; | ||
@@ -58,3 +59,3 @@ * | ||
* import { Logger } from '@aws-lambda-powertools/logger'; | ||
* import { LambdaInterface } from '@aws-lambda-powertools/commons'; | ||
* import type { LambdaInterface } from '@aws-lambda-powertools/commons/types'; | ||
* | ||
@@ -93,3 +94,3 @@ * const logger = new Logger(); | ||
* @implements {ClassThatLogs} | ||
* @see https://docs.powertools.aws.dev/lambda-typescript/latest/core/logger/ | ||
* @see https://docs.powertools.aws.dev/lambda/typescript/latest/core/logger/ | ||
*/ | ||
@@ -237,3 +238,3 @@ declare class Logger extends Utility implements LoggerInterface { | ||
* import { Logger } from '@aws-lambda-powertools/logger'; | ||
* import { LambdaInterface } from '@aws-lambda-powertools/commons'; | ||
* import type { LambdaInterface } from '@aws-lambda-powertools/commons/types'; | ||
* | ||
@@ -240,0 +241,0 @@ * const logger = new Logger(); |
@@ -27,3 +27,3 @@ "use strict"; | ||
* | ||
* For more usage examples, see [our documentation](https://docs.powertools.aws.dev/lambda-typescript/latest/core/logger/). | ||
* For more usage examples, see [our documentation](https://docs.powertools.aws.dev/lambda/typescript/latest/core/logger/). | ||
* | ||
@@ -47,3 +47,4 @@ * ### Basic usage | ||
* ```typescript | ||
* import { Logger, injectLambdaContext } from '@aws-lambda-powertools/logger'; | ||
* import { Logger } from '@aws-lambda-powertools/logger'; | ||
* import { injectLambdaContext } from '@aws-lambda-powertools/logger/middleware'; | ||
* import middy from '@middy/core'; | ||
@@ -67,3 +68,3 @@ * | ||
* import { Logger } from '@aws-lambda-powertools/logger'; | ||
* import { LambdaInterface } from '@aws-lambda-powertools/commons'; | ||
* import type { LambdaInterface } from '@aws-lambda-powertools/commons/types'; | ||
* | ||
@@ -102,43 +103,6 @@ * const logger = new Logger(); | ||
* @implements {ClassThatLogs} | ||
* @see https://docs.powertools.aws.dev/lambda-typescript/latest/core/logger/ | ||
* @see https://docs.powertools.aws.dev/lambda/typescript/latest/core/logger/ | ||
*/ | ||
class Logger extends commons_1.Utility { | ||
/** | ||
* Console instance used to print logs. | ||
* | ||
* In AWS Lambda, we create a new instance of the Console class so that we can have | ||
* full control over the output of the logs. In testing environments, we use the | ||
* default console instance. | ||
* | ||
* This property is initialized in the constructor in setOptions(). | ||
* | ||
* @private | ||
*/ | ||
console; | ||
customConfigService; | ||
// envVarsService is always initialized in the constructor in setOptions() | ||
envVarsService; | ||
logEvent = false; | ||
logFormatter; | ||
logIndentation = constants_js_1.LogJsonIndent.COMPACT; | ||
/** | ||
* Log level used internally by the current instance of Logger. | ||
*/ | ||
logLevel = 12; | ||
/** | ||
* Log level thresholds used internally by the current instance of Logger. | ||
* | ||
* The levels are in ascending order from the most verbose to the least verbose (no logs). | ||
*/ | ||
logLevelThresholds = { | ||
DEBUG: 8, | ||
INFO: 12, | ||
WARN: 16, | ||
ERROR: 20, | ||
CRITICAL: 24, | ||
SILENT: 28, | ||
}; | ||
persistentLogAttributes = {}; | ||
powertoolsLogData = {}; | ||
/** | ||
* Log level used by the current instance of Logger. | ||
@@ -159,2 +123,23 @@ * | ||
super(); | ||
this.logEvent = false; | ||
this.logIndentation = constants_js_1.LogJsonIndent.COMPACT; | ||
/** | ||
* Log level used internally by the current instance of Logger. | ||
*/ | ||
this.logLevel = 12; | ||
/** | ||
* Log level thresholds used internally by the current instance of Logger. | ||
* | ||
* The levels are in ascending order from the most verbose to the least verbose (no logs). | ||
*/ | ||
this.logLevelThresholds = { | ||
DEBUG: 8, | ||
INFO: 12, | ||
WARN: 16, | ||
ERROR: 20, | ||
CRITICAL: 24, | ||
SILENT: 28, | ||
}; | ||
this.persistentLogAttributes = {}; | ||
this.powertoolsLogData = {}; | ||
this.setOptions(options); | ||
@@ -305,3 +290,3 @@ } | ||
* import { Logger } from '@aws-lambda-powertools/logger'; | ||
* import { LambdaInterface } from '@aws-lambda-powertools/commons'; | ||
* import type { LambdaInterface } from '@aws-lambda-powertools/commons/types'; | ||
* | ||
@@ -366,3 +351,3 @@ * const logger = new Logger(); | ||
let shouldLogEvent = undefined; | ||
if (Object.hasOwn(options || {}, 'logEvent')) { | ||
if (options && options.hasOwnProperty('logEvent')) { | ||
shouldLogEvent = options.logEvent; | ||
@@ -411,3 +396,3 @@ } | ||
for (const key of keys) { | ||
if (Object.hasOwn(this.persistentLogAttributes, key)) { | ||
if (this.persistentLogAttributes && key in this.persistentLogAttributes) { | ||
delete this.persistentLogAttributes[key]; | ||
@@ -414,0 +399,0 @@ } |
@@ -11,3 +11,4 @@ import { Logger } from '../Logger.js'; | ||
* ```typescript | ||
* import { Logger, injectLambdaContext } from '@aws-lambda-powertools/logger'; | ||
* import { Logger } from '@aws-lambda-powertools/logger'; | ||
* import { injectLambdaContext } from '@aws-lambda-powertools/logger/middleware'; | ||
* import middy from '@middy/core'; | ||
@@ -14,0 +15,0 @@ * |
@@ -13,3 +13,4 @@ "use strict"; | ||
* ```typescript | ||
* import { Logger, injectLambdaContext } from '@aws-lambda-powertools/logger'; | ||
* import { Logger } from '@aws-lambda-powertools/logger'; | ||
* import { injectLambdaContext } from '@aws-lambda-powertools/logger/middleware'; | ||
* import middy from '@middy/core'; | ||
@@ -16,0 +17,0 @@ * |
@@ -7,3 +7,3 @@ import type { ConfigServiceInterface as ConfigServiceBaseInterface } from '@aws-lambda-powertools/commons/types'; | ||
* @see https://docs.aws.amazon.com/lambda/latest/dg/configuration-envvars.html#configuration-envvars-runtime | ||
* @see https://docs.powertools.aws.dev/lambda-typescript/latest/#environment-variables | ||
* @see https://docs.powertools.aws.dev/lambda/typescript/latest/#environment-variables | ||
*/ | ||
@@ -10,0 +10,0 @@ interface ConfigServiceInterface extends ConfigServiceBaseInterface { |
@@ -15,3 +15,3 @@ import { ConfigServiceInterface } from '../types/ConfigServiceInterface.js'; | ||
* @see https://docs.aws.amazon.com/lambda/latest/dg/configuration-envvars.html#configuration-envvars-runtime | ||
* @see https://docs.powertools.aws.dev/lambda-typescript/latest/#environment-variables | ||
* @see https://docs.powertools.aws.dev/lambda/typescript/latest/#environment-variables | ||
*/ | ||
@@ -100,10 +100,4 @@ declare class EnvironmentVariablesService extends CommonEnvironmentVariablesService implements ConfigServiceInterface { | ||
getTimezone(): string; | ||
/** | ||
* It returns true if the POWERTOOLS_DEV environment variable is set to truthy value. | ||
* | ||
* @returns {boolean} | ||
*/ | ||
isDevMode(): boolean; | ||
} | ||
export { EnvironmentVariablesService }; | ||
//# sourceMappingURL=EnvironmentVariablesService.d.ts.map |
@@ -14,17 +14,20 @@ import { EnvironmentVariablesService as CommonEnvironmentVariablesService } from '@aws-lambda-powertools/commons'; | ||
* @see https://docs.aws.amazon.com/lambda/latest/dg/configuration-envvars.html#configuration-envvars-runtime | ||
* @see https://docs.powertools.aws.dev/lambda-typescript/latest/#environment-variables | ||
* @see https://docs.powertools.aws.dev/lambda/typescript/latest/#environment-variables | ||
*/ | ||
class EnvironmentVariablesService extends CommonEnvironmentVariablesService { | ||
// Reserved environment variables | ||
awsLogLevelVariable = 'AWS_LAMBDA_LOG_LEVEL'; | ||
awsRegionVariable = 'AWS_REGION'; | ||
currentEnvironmentVariable = 'ENVIRONMENT'; | ||
functionNameVariable = 'AWS_LAMBDA_FUNCTION_NAME'; | ||
functionVersionVariable = 'AWS_LAMBDA_FUNCTION_VERSION'; | ||
logEventVariable = 'POWERTOOLS_LOGGER_LOG_EVENT'; | ||
logLevelVariable = 'POWERTOOLS_LOG_LEVEL'; | ||
logLevelVariableLegacy = 'LOG_LEVEL'; | ||
memoryLimitInMBVariable = 'AWS_LAMBDA_FUNCTION_MEMORY_SIZE'; | ||
sampleRateValueVariable = 'POWERTOOLS_LOGGER_SAMPLE_RATE'; | ||
tzVariable = 'TZ'; | ||
constructor() { | ||
super(...arguments); | ||
// Reserved environment variables | ||
this.awsLogLevelVariable = 'AWS_LAMBDA_LOG_LEVEL'; | ||
this.awsRegionVariable = 'AWS_REGION'; | ||
this.currentEnvironmentVariable = 'ENVIRONMENT'; | ||
this.functionNameVariable = 'AWS_LAMBDA_FUNCTION_NAME'; | ||
this.functionVersionVariable = 'AWS_LAMBDA_FUNCTION_VERSION'; | ||
this.logEventVariable = 'POWERTOOLS_LOGGER_LOG_EVENT'; | ||
this.logLevelVariable = 'POWERTOOLS_LOG_LEVEL'; | ||
this.logLevelVariableLegacy = 'LOG_LEVEL'; | ||
this.memoryLimitInMBVariable = 'AWS_LAMBDA_FUNCTION_MEMORY_SIZE'; | ||
this.sampleRateValueVariable = 'POWERTOOLS_LOGGER_SAMPLE_RATE'; | ||
this.tzVariable = 'TZ'; | ||
} | ||
/** | ||
@@ -127,12 +130,3 @@ * It returns the value of the `AWS_LAMBDA_LOG_LEVEL` environment variable. | ||
} | ||
/** | ||
* It returns true if the POWERTOOLS_DEV environment variable is set to truthy value. | ||
* | ||
* @returns {boolean} | ||
*/ | ||
isDevMode() { | ||
const value = this.get(this.devModeVariable); | ||
return this.isValueTrue(value); | ||
} | ||
} | ||
export { EnvironmentVariablesService }; |
/** | ||
* Typeguard to monkey patch Error to add a cause property. | ||
* | ||
* This is needed because the `cause` property is present in ES2022 or newer. | ||
* Since we want to be able to format errors in Node 16.x, we need to | ||
* add this property ourselves. We can remove this once we drop support | ||
* for Node 16.x. | ||
* | ||
* @see https://nodejs.org/api/errors.html#errors_error_cause | ||
*/ | ||
const isErrorWithCause = (error) => { | ||
return 'cause' in error; | ||
}; | ||
/** | ||
* This class defines and implements common methods for the formatting of log attributes. | ||
@@ -9,7 +22,2 @@ * | ||
class LogFormatter { | ||
/** | ||
* EnvironmentVariablesService instance. | ||
* If set, it allows to access environment variables. | ||
*/ | ||
envVarsService; | ||
constructor(options) { | ||
@@ -30,5 +38,7 @@ this.envVarsService = options?.envVarsService; | ||
stack: error.stack, | ||
cause: error.cause instanceof Error | ||
? this.formatError(error.cause) | ||
: error.cause, | ||
cause: isErrorWithCause(error) | ||
? error.cause instanceof Error | ||
? this.formatError(error.cause) | ||
: error.cause | ||
: undefined, | ||
}; | ||
@@ -35,0 +45,0 @@ } |
import merge from 'lodash.merge'; | ||
class LogItem { | ||
attributes = {}; | ||
constructor(params) { | ||
this.attributes = {}; | ||
// Add attributes in the log item in this order: | ||
@@ -6,0 +6,0 @@ // - Base attributes supported by the Powertool by default |
@@ -18,3 +18,3 @@ import { Utility } from '@aws-lambda-powertools/commons'; | ||
* | ||
* For more usage examples, see [our documentation](https://docs.powertools.aws.dev/lambda-typescript/latest/core/logger/). | ||
* For more usage examples, see [our documentation](https://docs.powertools.aws.dev/lambda/typescript/latest/core/logger/). | ||
* | ||
@@ -38,3 +38,4 @@ * ### Basic usage | ||
* ```typescript | ||
* import { Logger, injectLambdaContext } from '@aws-lambda-powertools/logger'; | ||
* import { Logger } from '@aws-lambda-powertools/logger'; | ||
* import { injectLambdaContext } from '@aws-lambda-powertools/logger/middleware'; | ||
* import middy from '@middy/core'; | ||
@@ -58,3 +59,3 @@ * | ||
* import { Logger } from '@aws-lambda-powertools/logger'; | ||
* import { LambdaInterface } from '@aws-lambda-powertools/commons'; | ||
* import type { LambdaInterface } from '@aws-lambda-powertools/commons/types'; | ||
* | ||
@@ -93,3 +94,3 @@ * const logger = new Logger(); | ||
* @implements {ClassThatLogs} | ||
* @see https://docs.powertools.aws.dev/lambda-typescript/latest/core/logger/ | ||
* @see https://docs.powertools.aws.dev/lambda/typescript/latest/core/logger/ | ||
*/ | ||
@@ -237,3 +238,3 @@ declare class Logger extends Utility implements LoggerInterface { | ||
* import { Logger } from '@aws-lambda-powertools/logger'; | ||
* import { LambdaInterface } from '@aws-lambda-powertools/commons'; | ||
* import type { LambdaInterface } from '@aws-lambda-powertools/commons/types'; | ||
* | ||
@@ -240,0 +241,0 @@ * const logger = new Logger(); |
@@ -21,3 +21,3 @@ import { Utility } from '@aws-lambda-powertools/commons'; | ||
* | ||
* For more usage examples, see [our documentation](https://docs.powertools.aws.dev/lambda-typescript/latest/core/logger/). | ||
* For more usage examples, see [our documentation](https://docs.powertools.aws.dev/lambda/typescript/latest/core/logger/). | ||
* | ||
@@ -41,3 +41,4 @@ * ### Basic usage | ||
* ```typescript | ||
* import { Logger, injectLambdaContext } from '@aws-lambda-powertools/logger'; | ||
* import { Logger } from '@aws-lambda-powertools/logger'; | ||
* import { injectLambdaContext } from '@aws-lambda-powertools/logger/middleware'; | ||
* import middy from '@middy/core'; | ||
@@ -61,3 +62,3 @@ * | ||
* import { Logger } from '@aws-lambda-powertools/logger'; | ||
* import { LambdaInterface } from '@aws-lambda-powertools/commons'; | ||
* import type { LambdaInterface } from '@aws-lambda-powertools/commons/types'; | ||
* | ||
@@ -96,43 +97,6 @@ * const logger = new Logger(); | ||
* @implements {ClassThatLogs} | ||
* @see https://docs.powertools.aws.dev/lambda-typescript/latest/core/logger/ | ||
* @see https://docs.powertools.aws.dev/lambda/typescript/latest/core/logger/ | ||
*/ | ||
class Logger extends Utility { | ||
/** | ||
* Console instance used to print logs. | ||
* | ||
* In AWS Lambda, we create a new instance of the Console class so that we can have | ||
* full control over the output of the logs. In testing environments, we use the | ||
* default console instance. | ||
* | ||
* This property is initialized in the constructor in setOptions(). | ||
* | ||
* @private | ||
*/ | ||
console; | ||
customConfigService; | ||
// envVarsService is always initialized in the constructor in setOptions() | ||
envVarsService; | ||
logEvent = false; | ||
logFormatter; | ||
logIndentation = LogJsonIndent.COMPACT; | ||
/** | ||
* Log level used internally by the current instance of Logger. | ||
*/ | ||
logLevel = 12; | ||
/** | ||
* Log level thresholds used internally by the current instance of Logger. | ||
* | ||
* The levels are in ascending order from the most verbose to the least verbose (no logs). | ||
*/ | ||
logLevelThresholds = { | ||
DEBUG: 8, | ||
INFO: 12, | ||
WARN: 16, | ||
ERROR: 20, | ||
CRITICAL: 24, | ||
SILENT: 28, | ||
}; | ||
persistentLogAttributes = {}; | ||
powertoolsLogData = {}; | ||
/** | ||
* Log level used by the current instance of Logger. | ||
@@ -153,2 +117,23 @@ * | ||
super(); | ||
this.logEvent = false; | ||
this.logIndentation = LogJsonIndent.COMPACT; | ||
/** | ||
* Log level used internally by the current instance of Logger. | ||
*/ | ||
this.logLevel = 12; | ||
/** | ||
* Log level thresholds used internally by the current instance of Logger. | ||
* | ||
* The levels are in ascending order from the most verbose to the least verbose (no logs). | ||
*/ | ||
this.logLevelThresholds = { | ||
DEBUG: 8, | ||
INFO: 12, | ||
WARN: 16, | ||
ERROR: 20, | ||
CRITICAL: 24, | ||
SILENT: 28, | ||
}; | ||
this.persistentLogAttributes = {}; | ||
this.powertoolsLogData = {}; | ||
this.setOptions(options); | ||
@@ -299,3 +284,3 @@ } | ||
* import { Logger } from '@aws-lambda-powertools/logger'; | ||
* import { LambdaInterface } from '@aws-lambda-powertools/commons'; | ||
* import type { LambdaInterface } from '@aws-lambda-powertools/commons/types'; | ||
* | ||
@@ -360,3 +345,3 @@ * const logger = new Logger(); | ||
let shouldLogEvent = undefined; | ||
if (Object.hasOwn(options || {}, 'logEvent')) { | ||
if (options && options.hasOwnProperty('logEvent')) { | ||
shouldLogEvent = options.logEvent; | ||
@@ -405,3 +390,3 @@ } | ||
for (const key of keys) { | ||
if (Object.hasOwn(this.persistentLogAttributes, key)) { | ||
if (this.persistentLogAttributes && key in this.persistentLogAttributes) { | ||
delete this.persistentLogAttributes[key]; | ||
@@ -408,0 +393,0 @@ } |
@@ -11,3 +11,4 @@ import { Logger } from '../Logger.js'; | ||
* ```typescript | ||
* import { Logger, injectLambdaContext } from '@aws-lambda-powertools/logger'; | ||
* import { Logger } from '@aws-lambda-powertools/logger'; | ||
* import { injectLambdaContext } from '@aws-lambda-powertools/logger/middleware'; | ||
* import middy from '@middy/core'; | ||
@@ -14,0 +15,0 @@ * |
@@ -10,3 +10,4 @@ import { Logger } from '../Logger.js'; | ||
* ```typescript | ||
* import { Logger, injectLambdaContext } from '@aws-lambda-powertools/logger'; | ||
* import { Logger } from '@aws-lambda-powertools/logger'; | ||
* import { injectLambdaContext } from '@aws-lambda-powertools/logger/middleware'; | ||
* import middy from '@middy/core'; | ||
@@ -13,0 +14,0 @@ * |
@@ -7,3 +7,3 @@ import type { ConfigServiceInterface as ConfigServiceBaseInterface } from '@aws-lambda-powertools/commons/types'; | ||
* @see https://docs.aws.amazon.com/lambda/latest/dg/configuration-envvars.html#configuration-envvars-runtime | ||
* @see https://docs.powertools.aws.dev/lambda-typescript/latest/#environment-variables | ||
* @see https://docs.powertools.aws.dev/lambda/typescript/latest/#environment-variables | ||
*/ | ||
@@ -10,0 +10,0 @@ interface ConfigServiceInterface extends ConfigServiceBaseInterface { |
{ | ||
"name": "@aws-lambda-powertools/logger", | ||
"version": "2.0.0-alpha.2", | ||
"version": "2.0.0", | ||
"description": "The logging package for the Powertools for AWS Lambda (TypeScript) library", | ||
@@ -28,3 +28,3 @@ "author": { | ||
"dependencies": { | ||
"@aws-lambda-powertools/commons": "^2.0.0-alpha.2", | ||
"@aws-lambda-powertools/commons": "^2.0.0", | ||
"lodash.merge": "^4.6.2" | ||
@@ -31,0 +31,0 @@ }, |
# Powertools for AWS Lambda (TypeScript) <!-- omit in toc --> | ||
Powertools for AWS Lambda (TypeScript) is a developer toolkit to implement Serverless [best practices and increase developer velocity](https://docs.powertools.aws.dev/lambda-typescript/latest/#features). | ||
Powertools for AWS Lambda (TypeScript) is a developer toolkit to implement Serverless [best practices and increase developer velocity](https://docs.powertools.aws.dev/lambda/typescript/latest/#features). | ||
You can use the library in both TypeScript and JavaScript code bases. | ||
> Also available in [Python](https://github.com/aws-powertools/powertools-lambda-python), [Java](https://github.com/aws-powertools/powertools-lambda-java), and [.NET](https://docs.powertools.aws.dev/lambda-dotnet/). | ||
> Also available in [Python](https://github.com/aws-powertools/powertools-lambda-python), [Java](https://github.com/aws-powertools/powertools-lambda-java), and [.NET](https://github.com/aws-powertools/powertools-lambda-dotnet). | ||
**[Documentation](https://docs.powertools.aws.dev/lambda-typescript/)** | **[npm](https://www.npmjs.com/org/aws-lambda-powertools)** | **[Roadmap](https://docs.powertools.aws.dev/lambda-typescript/latest/roadmap)** | **[Examples](https://github.com/aws-powertools/powertools-lambda-typescript/tree/main/examples)** | **[Serverless TypeScript Demo](https://github.com/aws-samples/serverless-typescript-demo)** | ||
**[Documentation](https://docs.powertools.aws.dev/lambda/typescript/)** | **[npm](https://www.npmjs.com/org/aws-lambda-powertools)** | **[Roadmap](https://docs.powertools.aws.dev/lambda/typescript/latest/roadmap)** | **[Examples](https://github.com/aws-powertools/powertools-lambda-typescript/tree/main/examples)** | **[Serverless TypeScript Demo](https://github.com/aws-samples/serverless-typescript-demo)** | ||
@@ -17,3 +17,3 @@ ## Table of contents <!-- omit in toc --> | ||
- [Examples](#examples) | ||
- [Serverless TypeScript Demo application](#serverless-typescript-demo-application) | ||
- [Demo applications](#demo-applications) | ||
- [Contribute](#contribute) | ||
@@ -31,10 +31,10 @@ - [Roadmap](#roadmap) | ||
* **[Tracer](https://docs.powertools.aws.dev/lambda-typescript/latest/core/tracer/)** - Utilities to trace Lambda function handlers, and both synchronous and asynchronous functions | ||
* **[Logger](https://docs.powertools.aws.dev/lambda-typescript/latest/core/logger/)** - Structured logging made easier, and a middleware to enrich log items with key details of the Lambda context | ||
* **[Metrics](https://docs.powertools.aws.dev/lambda-typescript/latest/core/metrics/)** - Custom Metrics created asynchronously via CloudWatch Embedded Metric Format (EMF) | ||
* **[Parameters](https://docs.powertools.aws.dev/lambda-typescript/latest/utilities/parameters/)** - High-level functions to retrieve one or more parameters from AWS SSM, Secrets Manager, AppConfig, and DynamoDB | ||
* **[Tracer](https://docs.powertools.aws.dev/lambda/typescript/latest/core/tracer/)** - Utilities to trace Lambda function handlers, and both synchronous and asynchronous functions | ||
* **[Logger](https://docs.powertools.aws.dev/lambda/typescript/latest/core/logger/)** - Structured logging made easier, and a middleware to enrich log items with key details of the Lambda context | ||
* **[Metrics](https://docs.powertools.aws.dev/lambda/typescript/latest/core/metrics/)** - Custom Metrics created asynchronously via CloudWatch Embedded Metric Format (EMF) | ||
* **[Parameters](https://docs.powertools.aws.dev/lambda/typescript/latest/utilities/parameters/)** - High-level functions to retrieve one or more parameters from AWS SSM, Secrets Manager, AppConfig, and DynamoDB | ||
## Getting started | ||
Find the complete project's [documentation here](https://docs.powertools.aws.dev/lambda-typescript). | ||
Find the complete project's [documentation here](https://docs.powertools.aws.dev/lambda/typescript). | ||
@@ -55,9 +55,9 @@ ### Installation | ||
π [Installation guide for the **Tracer** utility](https://docs.powertools.aws.dev/lambda-typescript/latest/core/tracer#getting-started) | ||
π [Installation guide for the **Tracer** utility](https://docs.powertools.aws.dev/lambda/typescript/latest/core/tracer#getting-started) | ||
π [Installation guide for the **Logger** utility](https://docs.powertools.aws.dev/lambda-typescript/latest/core/logger#getting-started) | ||
π [Installation guide for the **Logger** utility](https://docs.powertools.aws.dev/lambda/typescript/latest/core/logger#getting-started) | ||
π [Installation guide for the **Metrics** utility](https://docs.powertools.aws.dev/lambda-typescript/latest/core/metrics#getting-started) | ||
π [Installation guide for the **Metrics** utility](https://docs.powertools.aws.dev/lambda/typescript/latest/core/metrics#getting-started) | ||
π [Installation guide for the **Parameters** utility](https://docs.powertools.aws.dev/lambda-typescript/latest/utilities/parameters/#getting-started) | ||
π [Installation guide for the **Parameters** utility](https://docs.powertools.aws.dev/lambda/typescript/latest/utilities/parameters/#getting-started) | ||
@@ -69,3 +69,3 @@ ### Examples | ||
### Serverless TypeScript Demo application | ||
### Demo applications | ||
@@ -75,2 +75,4 @@ The [Serverless TypeScript Demo](https://github.com/aws-samples/serverless-typescript-demo) shows how to use Powertools for AWS Lambda (TypeScript). | ||
The [AWS Lambda performance tuning](https://github.com/aws-samples/optimizations-for-lambda-functions) repository also uses Powertools for AWS Lambda (TypeScript) as well as demonstrating other performance tuning techniques for Lambda functions written in TypeScript. | ||
## Contribute | ||
@@ -107,6 +109,8 @@ | ||
* [tecRacer GmbH & Co. KG](https://www.tecracer.com/) | ||
* [AppYourself](https://appyourself.net) | ||
* [Alma Media](https://www.almamedia.fi) | ||
### Sharing your work | ||
Share what you did with Powertools for AWS Lambda (TypeScript) ππ. Blog post, workshops, presentation, sample apps and others. Check out what the community has already shared about Powertools for AWS Lambda (TypeScript) [here](https://docs.powertools.aws.dev/lambda-typescript/latest/we_made_this). | ||
Share what you did with Powertools for AWS Lambda (TypeScript) ππ. Blog post, workshops, presentation, sample apps and others. Check out what the community has already shared about Powertools for AWS Lambda (TypeScript) [here](https://docs.powertools.aws.dev/lambda/typescript/latest/we_made_this). | ||
@@ -113,0 +117,0 @@ ### Using Lambda Layer |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
199691
78
0
0
121
4516