Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@aws-lambda-powertools/logger

Package Overview
Dependencies
Maintainers
2
Versions
96
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aws-lambda-powertools/logger - npm Package Compare versions

Comparing version 2.0.0-alpha.1 to 2.0.0-alpha.2

28

lib/cjs/config/EnvironmentVariablesService.d.ts

@@ -18,5 +18,5 @@ import { ConfigServiceInterface } from '../types/ConfigServiceInterface.js';

declare class EnvironmentVariablesService extends CommonEnvironmentVariablesService implements ConfigServiceInterface {
private awsLogLevelVariable;
private awsRegionVariable;
private currentEnvironmentVariable;
private devModeVariable;
private functionNameVariable;

@@ -26,5 +26,19 @@ private functionVersionVariable;

private logLevelVariable;
private logLevelVariableLegacy;
private memoryLimitInMBVariable;
private sampleRateValueVariable;
private tzVariable;
/**
* It returns the value of the `AWS_LAMBDA_LOG_LEVEL` environment variable.
*
* The `AWS_LAMBDA_LOG_LEVEL` environment variable is set by AWS Lambda when configuring
* the function's log level using the Advanced Logging Controls feature. This value always
* takes precedence over other means of configuring the log level.
*
* @note we need to map the `FATAL` log level to `CRITICAL`, see {@link https://docs.aws.amazon.com/lambda/latest/dg/configuration-logging.html#configuration-logging-log-levels AWS Lambda Log Levels}.
*
* @returns {string}
*/
getAwsLogLevel(): string;
/**
* It returns the value of the AWS_REGION environment variable.

@@ -66,4 +80,8 @@ *

/**
* It returns the value of the LOG_LEVEL environment variable.
* It returns the value of the `POWERTOOLS_LOG_LEVEL, or `LOG_LEVEL` (legacy) environment variables
* when the first one is not set.
*
* @note The `LOG_LEVEL` environment variable is considered legacy and will be removed in a future release.
* @note The `AWS_LAMBDA_LOG_LEVEL` environment variable always takes precedence over the ones above.
*
* @returns {string}

@@ -79,2 +97,8 @@ */

/**
* It returns the value of the `TZ` environment variable or `UTC` if it is not set.
*
* @returns {string}
*/
getTimezone(): string;
/**
* It returns true if the POWERTOOLS_DEV environment variable is set to truthy value.

@@ -81,0 +105,0 @@ *

@@ -21,12 +21,29 @@ "use strict";

// Reserved environment variables
awsLogLevelVariable = 'AWS_LAMBDA_LOG_LEVEL';
awsRegionVariable = 'AWS_REGION';
currentEnvironmentVariable = 'ENVIRONMENT';
devModeVariable = 'POWERTOOLS_DEV';
functionNameVariable = 'AWS_LAMBDA_FUNCTION_NAME';
functionVersionVariable = 'AWS_LAMBDA_FUNCTION_VERSION';
logEventVariable = 'POWERTOOLS_LOGGER_LOG_EVENT';
logLevelVariable = 'LOG_LEVEL';
logLevelVariable = 'POWERTOOLS_LOG_LEVEL';
logLevelVariableLegacy = 'LOG_LEVEL';
memoryLimitInMBVariable = 'AWS_LAMBDA_FUNCTION_MEMORY_SIZE';
sampleRateValueVariable = 'POWERTOOLS_LOGGER_SAMPLE_RATE';
tzVariable = 'TZ';
/**
* It returns the value of the `AWS_LAMBDA_LOG_LEVEL` environment variable.
*
* The `AWS_LAMBDA_LOG_LEVEL` environment variable is set by AWS Lambda when configuring
* the function's log level using the Advanced Logging Controls feature. This value always
* takes precedence over other means of configuring the log level.
*
* @note we need to map the `FATAL` log level to `CRITICAL`, see {@link https://docs.aws.amazon.com/lambda/latest/dg/configuration-logging.html#configuration-logging-log-levels AWS Lambda Log Levels}.
*
* @returns {string}
*/
getAwsLogLevel() {
const awsLogLevelVariable = this.get(this.awsLogLevelVariable);
return awsLogLevelVariable === 'FATAL' ? 'CRITICAL' : awsLogLevelVariable;
}
/**
* It returns the value of the AWS_REGION environment variable.

@@ -82,8 +99,14 @@ *

/**
* It returns the value of the LOG_LEVEL environment variable.
* It returns the value of the `POWERTOOLS_LOG_LEVEL, or `LOG_LEVEL` (legacy) environment variables
* when the first one is not set.
*
* @note The `LOG_LEVEL` environment variable is considered legacy and will be removed in a future release.
* @note The `AWS_LAMBDA_LOG_LEVEL` environment variable always takes precedence over the ones above.
*
* @returns {string}
*/
getLogLevel() {
return this.get(this.logLevelVariable);
const logLevelVariable = this.get(this.logLevelVariable);
const logLevelVariableAlias = this.get(this.logLevelVariableLegacy);
return logLevelVariable !== '' ? logLevelVariable : logLevelVariableAlias;
}

@@ -100,2 +123,11 @@ /**

/**
* It returns the value of the `TZ` environment variable or `UTC` if it is not set.
*
* @returns {string}
*/
getTimezone() {
const value = this.get(this.tzVariable);
return value.length > 0 ? value : 'UTC';
}
/**
* It returns true if the POWERTOOLS_DEV environment variable is set to truthy value.

@@ -102,0 +134,0 @@ *

@@ -1,2 +0,3 @@

import type { LogAttributes, LogFormatterInterface } from '../types/Log.js';
import type { EnvironmentVariablesService } from '../config/EnvironmentVariablesService.js';
import type { LogAttributes, LogFormatterInterface, LogFormatterOptions } from '../types/Log.js';
import type { UnformattedAttributes } from '../types/Logger.js';

@@ -13,2 +14,8 @@ import { LogItem } from './LogItem.js';

/**
* EnvironmentVariablesService instance.
* If set, it allows to access environment variables.
*/
protected envVarsService?: EnvironmentVariablesService;
constructor(options?: LogFormatterOptions);
/**
* It formats key-value pairs of log attributes.

@@ -15,0 +22,0 @@ *

@@ -13,2 +13,10 @@ "use strict";

/**
* EnvironmentVariablesService instance.
* If set, it allows to access environment variables.
*/
envVarsService;
constructor(options) {
this.envVarsService = options?.envVarsService;
}
/**
* It formats a given Error parameter.

@@ -15,0 +23,0 @@ *

13

lib/cjs/Logger.d.ts

@@ -288,2 +288,5 @@ import { Utility } from '@aws-lambda-powertools/commons';

*
* If the log level is set using AWS Lambda Advanced Logging Controls, it sets it
* instead of the given log level to avoid data loss.
*
* @param logLevel The log level to set, i.e. `error`, `warn`, `info`, `debug`, etc.

@@ -347,2 +350,3 @@ */

private addToPowertoolsLogData;
private awsLogLevelShortCircuit;
/**

@@ -469,7 +473,8 @@ * It processes a particular log item so that it can be printed to stdout:

* Sets the initial Logger log level based on the following order:
* 1. If a log level is passed to the constructor, it sets it.
* 2. If a log level is set via custom config service, it sets it.
* 3. If a log level is set via env variables, it sets it.
* 1. If a log level is set using AWS Lambda Advanced Logging Controls, it sets it.
* 2. If a log level is passed to the constructor, it sets it.
* 3. If a log level is set via custom config service, it sets it.
* 4. If a log level is set via env variables, it sets it.
*
* If none of the above is true, the default log level applies (INFO).
* If none of the above is true, the default log level applies (`INFO`).
*

@@ -476,0 +481,0 @@ * @private

@@ -9,2 +9,3 @@ "use strict";

const lodash_merge_1 = __importDefault(require("lodash.merge"));
const node_util_1 = require("node:util");
const node_console_1 = require("node:console");

@@ -412,5 +413,10 @@ const node_crypto_1 = require("node:crypto");

*
* If the log level is set using AWS Lambda Advanced Logging Controls, it sets it
* instead of the given log level to avoid data loss.
*
* @param logLevel The log level to set, i.e. `error`, `warn`, `info`, `debug`, etc.
*/
setLogLevel(logLevel) {
if (this.awsLogLevelShortCircuit(logLevel))
return;
if (this.isValidLogLevel(logLevel)) {

@@ -491,2 +497,14 @@ this.logLevel = this.logLevelThresholds[logLevel];

}
awsLogLevelShortCircuit(selectedLogLevel) {
const awsLogLevel = this.getEnvVarsService().getAwsLogLevel();
if (this.isValidLogLevel(awsLogLevel)) {
this.logLevel = this.logLevelThresholds[awsLogLevel];
if (this.isValidLogLevel(selectedLogLevel) &&
this.logLevel > this.logLevelThresholds[selectedLogLevel]) {
this.warn((0, node_util_1.format)(`Current log level (%s) does not match AWS Lambda Advanced Logging Controls minimum log level (%s). This can lead to data loss, consider adjusting them.`, selectedLogLevel, awsLogLevel));
}
return true;
}
return false;
}
/**

@@ -703,7 +721,8 @@ * It processes a particular log item so that it can be printed to stdout:

* Sets the initial Logger log level based on the following order:
* 1. If a log level is passed to the constructor, it sets it.
* 2. If a log level is set via custom config service, it sets it.
* 3. If a log level is set via env variables, it sets it.
* 1. If a log level is set using AWS Lambda Advanced Logging Controls, it sets it.
* 2. If a log level is passed to the constructor, it sets it.
* 3. If a log level is set via custom config service, it sets it.
* 4. If a log level is set via env variables, it sets it.
*
* If none of the above is true, the default log level applies (INFO).
* If none of the above is true, the default log level applies (`INFO`).
*

@@ -715,2 +734,4 @@ * @private

const constructorLogLevel = logLevel?.toUpperCase();
if (this.awsLogLevelShortCircuit(constructorLogLevel))
return;
if (this.isValidLogLevel(constructorLogLevel)) {

@@ -781,3 +802,5 @@ this.logLevel = this.logLevelThresholds[constructorLogLevel];

setLogFormatter(logFormatter) {
this.logFormatter = logFormatter ?? new PowertoolsLogFormatter_js_1.PowertoolsLogFormatter();
this.logFormatter =
logFormatter ??
new PowertoolsLogFormatter_js_1.PowertoolsLogFormatter({ envVarsService: this.getEnvVarsService() });
}

@@ -806,4 +829,4 @@ /**

const { logLevel, serviceName, sampleRateValue, logFormatter, customConfigService, persistentLogAttributes, environment, } = options;
// order is important, EnvVarsService() is used by other methods
this.setEnvVarsService();
// order is important, it uses EnvVarsService()
this.setConsole();

@@ -810,0 +833,0 @@ this.setCustomConfigService(customConfigService);

@@ -0,1 +1,2 @@

import type { ConfigServiceInterface as ConfigServiceBaseInterface } from '@aws-lambda-powertools/commons/types';
/**

@@ -8,10 +9,15 @@ * Interface ConfigServiceInterface

*/
interface ConfigServiceInterface {
interface ConfigServiceInterface extends ConfigServiceBaseInterface {
/**
* It returns the value of an environment variable that has given name.
* It returns the value of the `AWS_LAMBDA_LOG_LEVEL` environment variable.
*
* @param {string} name
* The `AWS_LAMBDA_LOG_LEVEL` environment variable is set by AWS Lambda when configuring
* the function's log level using the Advanced Logging Controls feature. This value always
* takes precedence over other means of configuring the log level.
*
* @note we need to map the `FATAL` log level to `CRITICAL`, see {@link https://docs.aws.amazon.com/lambda/latest/dg/configuration-logging.html#configuration-logging-log-levels AWS Lambda Log Levels}.
*
* @returns {string}
*/
get(name: string): string;
getAwsLogLevel(): string;
/**

@@ -30,4 +36,8 @@ * It returns the value of the ENVIRONMENT environment variable.

/**
* It returns the value of the LOG_LEVEL environment variable.
* It returns the value of the `POWERTOOLS_LOG_LEVEL, or `LOG_LEVEL` (legacy) environment variables
* when the first one is not set.
*
* @note The `LOG_LEVEL` environment variable is considered legacy and will be removed in a future release.
* @note The `AWS_LAMBDA_LOG_LEVEL` environment variable always takes precedence over the ones above.
*
* @returns {string}

@@ -42,23 +52,4 @@ */

getSampleRateValue(): number | undefined;
/**
* It returns the value of the POWERTOOLS_SERVICE_NAME environment variable.
*
* @returns {string}
*/
getServiceName(): string;
/**
* It returns the value of the POWERTOOLS_DEV environment variable.
*
* @returns {boolean}
*/
isDevMode(): boolean;
/**
* It returns true if the string value represents a boolean true value.
*
* @param {string} value
* @returns boolean
*/
isValueTrue(value: string): boolean;
}
export type { ConfigServiceInterface };
//# sourceMappingURL=ConfigServiceInterface.d.ts.map

@@ -0,1 +1,2 @@

import type { EnvironmentVariablesService } from '../config/EnvironmentVariablesService.js';
import type { LogItem } from '../formatter/LogItem.js';

@@ -99,2 +100,9 @@ import type { UnformattedAttributes } from './Logger.js';

}
type LogFormatterOptions = {
/**
* EnvironmentVariablesService instance.
* If set, it gives the LogFormatter access to environment variables.
*/
envVarsService?: EnvironmentVariablesService;
};
/**

@@ -134,3 +142,3 @@ * @interface

}
export type { LogAttributesWithMessage, LogAttributeValue, Environment, LogLevelThresholds, LogAttributes, LogLevel, PowertoolsLog, LogItemInterface, LogFormatterInterface, };
export type { LogAttributesWithMessage, LogAttributeValue, Environment, LogLevelThresholds, LogAttributes, LogLevel, PowertoolsLog, LogItemInterface, LogFormatterOptions, LogFormatterInterface, };
//# sourceMappingURL=Log.d.ts.map

@@ -18,5 +18,5 @@ import { ConfigServiceInterface } from '../types/ConfigServiceInterface.js';

declare class EnvironmentVariablesService extends CommonEnvironmentVariablesService implements ConfigServiceInterface {
private awsLogLevelVariable;
private awsRegionVariable;
private currentEnvironmentVariable;
private devModeVariable;
private functionNameVariable;

@@ -26,5 +26,19 @@ private functionVersionVariable;

private logLevelVariable;
private logLevelVariableLegacy;
private memoryLimitInMBVariable;
private sampleRateValueVariable;
private tzVariable;
/**
* It returns the value of the `AWS_LAMBDA_LOG_LEVEL` environment variable.
*
* The `AWS_LAMBDA_LOG_LEVEL` environment variable is set by AWS Lambda when configuring
* the function's log level using the Advanced Logging Controls feature. This value always
* takes precedence over other means of configuring the log level.
*
* @note we need to map the `FATAL` log level to `CRITICAL`, see {@link https://docs.aws.amazon.com/lambda/latest/dg/configuration-logging.html#configuration-logging-log-levels AWS Lambda Log Levels}.
*
* @returns {string}
*/
getAwsLogLevel(): string;
/**
* It returns the value of the AWS_REGION environment variable.

@@ -66,4 +80,8 @@ *

/**
* It returns the value of the LOG_LEVEL environment variable.
* It returns the value of the `POWERTOOLS_LOG_LEVEL, or `LOG_LEVEL` (legacy) environment variables
* when the first one is not set.
*
* @note The `LOG_LEVEL` environment variable is considered legacy and will be removed in a future release.
* @note The `AWS_LAMBDA_LOG_LEVEL` environment variable always takes precedence over the ones above.
*
* @returns {string}

@@ -79,2 +97,8 @@ */

/**
* It returns the value of the `TZ` environment variable or `UTC` if it is not set.
*
* @returns {string}
*/
getTimezone(): string;
/**
* It returns true if the POWERTOOLS_DEV environment variable is set to truthy value.

@@ -81,0 +105,0 @@ *

@@ -18,12 +18,29 @@ import { EnvironmentVariablesService as CommonEnvironmentVariablesService } from '@aws-lambda-powertools/commons';

// Reserved environment variables
awsLogLevelVariable = 'AWS_LAMBDA_LOG_LEVEL';
awsRegionVariable = 'AWS_REGION';
currentEnvironmentVariable = 'ENVIRONMENT';
devModeVariable = 'POWERTOOLS_DEV';
functionNameVariable = 'AWS_LAMBDA_FUNCTION_NAME';
functionVersionVariable = 'AWS_LAMBDA_FUNCTION_VERSION';
logEventVariable = 'POWERTOOLS_LOGGER_LOG_EVENT';
logLevelVariable = 'LOG_LEVEL';
logLevelVariable = 'POWERTOOLS_LOG_LEVEL';
logLevelVariableLegacy = 'LOG_LEVEL';
memoryLimitInMBVariable = 'AWS_LAMBDA_FUNCTION_MEMORY_SIZE';
sampleRateValueVariable = 'POWERTOOLS_LOGGER_SAMPLE_RATE';
tzVariable = 'TZ';
/**
* It returns the value of the `AWS_LAMBDA_LOG_LEVEL` environment variable.
*
* The `AWS_LAMBDA_LOG_LEVEL` environment variable is set by AWS Lambda when configuring
* the function's log level using the Advanced Logging Controls feature. This value always
* takes precedence over other means of configuring the log level.
*
* @note we need to map the `FATAL` log level to `CRITICAL`, see {@link https://docs.aws.amazon.com/lambda/latest/dg/configuration-logging.html#configuration-logging-log-levels AWS Lambda Log Levels}.
*
* @returns {string}
*/
getAwsLogLevel() {
const awsLogLevelVariable = this.get(this.awsLogLevelVariable);
return awsLogLevelVariable === 'FATAL' ? 'CRITICAL' : awsLogLevelVariable;
}
/**
* It returns the value of the AWS_REGION environment variable.

@@ -79,8 +96,14 @@ *

/**
* It returns the value of the LOG_LEVEL environment variable.
* It returns the value of the `POWERTOOLS_LOG_LEVEL, or `LOG_LEVEL` (legacy) environment variables
* when the first one is not set.
*
* @note The `LOG_LEVEL` environment variable is considered legacy and will be removed in a future release.
* @note The `AWS_LAMBDA_LOG_LEVEL` environment variable always takes precedence over the ones above.
*
* @returns {string}
*/
getLogLevel() {
return this.get(this.logLevelVariable);
const logLevelVariable = this.get(this.logLevelVariable);
const logLevelVariableAlias = this.get(this.logLevelVariableLegacy);
return logLevelVariable !== '' ? logLevelVariable : logLevelVariableAlias;
}

@@ -97,2 +120,11 @@ /**

/**
* It returns the value of the `TZ` environment variable or `UTC` if it is not set.
*
* @returns {string}
*/
getTimezone() {
const value = this.get(this.tzVariable);
return value.length > 0 ? value : 'UTC';
}
/**
* It returns true if the POWERTOOLS_DEV environment variable is set to truthy value.

@@ -99,0 +131,0 @@ *

@@ -1,2 +0,3 @@

import type { LogAttributes, LogFormatterInterface } from '../types/Log.js';
import type { EnvironmentVariablesService } from '../config/EnvironmentVariablesService.js';
import type { LogAttributes, LogFormatterInterface, LogFormatterOptions } from '../types/Log.js';
import type { UnformattedAttributes } from '../types/Logger.js';

@@ -13,2 +14,8 @@ import { LogItem } from './LogItem.js';

/**
* EnvironmentVariablesService instance.
* If set, it allows to access environment variables.
*/
protected envVarsService?: EnvironmentVariablesService;
constructor(options?: LogFormatterOptions);
/**
* It formats key-value pairs of log attributes.

@@ -15,0 +22,0 @@ *

@@ -10,2 +10,10 @@ /**

/**
* EnvironmentVariablesService instance.
* If set, it allows to access environment variables.
*/
envVarsService;
constructor(options) {
this.envVarsService = options?.envVarsService;
}
/**
* It formats a given Error parameter.

@@ -12,0 +20,0 @@ *

@@ -288,2 +288,5 @@ import { Utility } from '@aws-lambda-powertools/commons';

*
* If the log level is set using AWS Lambda Advanced Logging Controls, it sets it
* instead of the given log level to avoid data loss.
*
* @param logLevel The log level to set, i.e. `error`, `warn`, `info`, `debug`, etc.

@@ -347,2 +350,3 @@ */

private addToPowertoolsLogData;
private awsLogLevelShortCircuit;
/**

@@ -469,7 +473,8 @@ * It processes a particular log item so that it can be printed to stdout:

* Sets the initial Logger log level based on the following order:
* 1. If a log level is passed to the constructor, it sets it.
* 2. If a log level is set via custom config service, it sets it.
* 3. If a log level is set via env variables, it sets it.
* 1. If a log level is set using AWS Lambda Advanced Logging Controls, it sets it.
* 2. If a log level is passed to the constructor, it sets it.
* 3. If a log level is set via custom config service, it sets it.
* 4. If a log level is set via env variables, it sets it.
*
* If none of the above is true, the default log level applies (INFO).
* If none of the above is true, the default log level applies (`INFO`).
*

@@ -476,0 +481,0 @@ * @private

import { Utility } from '@aws-lambda-powertools/commons';
import merge from 'lodash.merge';
import { format } from 'node:util';
import { Console } from 'node:console';

@@ -405,5 +406,10 @@ import { randomInt } from 'node:crypto';

*
* If the log level is set using AWS Lambda Advanced Logging Controls, it sets it
* instead of the given log level to avoid data loss.
*
* @param logLevel The log level to set, i.e. `error`, `warn`, `info`, `debug`, etc.
*/
setLogLevel(logLevel) {
if (this.awsLogLevelShortCircuit(logLevel))
return;
if (this.isValidLogLevel(logLevel)) {

@@ -484,2 +490,14 @@ this.logLevel = this.logLevelThresholds[logLevel];

}
awsLogLevelShortCircuit(selectedLogLevel) {
const awsLogLevel = this.getEnvVarsService().getAwsLogLevel();
if (this.isValidLogLevel(awsLogLevel)) {
this.logLevel = this.logLevelThresholds[awsLogLevel];
if (this.isValidLogLevel(selectedLogLevel) &&
this.logLevel > this.logLevelThresholds[selectedLogLevel]) {
this.warn(format(`Current log level (%s) does not match AWS Lambda Advanced Logging Controls minimum log level (%s). This can lead to data loss, consider adjusting them.`, selectedLogLevel, awsLogLevel));
}
return true;
}
return false;
}
/**

@@ -696,7 +714,8 @@ * It processes a particular log item so that it can be printed to stdout:

* Sets the initial Logger log level based on the following order:
* 1. If a log level is passed to the constructor, it sets it.
* 2. If a log level is set via custom config service, it sets it.
* 3. If a log level is set via env variables, it sets it.
* 1. If a log level is set using AWS Lambda Advanced Logging Controls, it sets it.
* 2. If a log level is passed to the constructor, it sets it.
* 3. If a log level is set via custom config service, it sets it.
* 4. If a log level is set via env variables, it sets it.
*
* If none of the above is true, the default log level applies (INFO).
* If none of the above is true, the default log level applies (`INFO`).
*

@@ -708,2 +727,4 @@ * @private

const constructorLogLevel = logLevel?.toUpperCase();
if (this.awsLogLevelShortCircuit(constructorLogLevel))
return;
if (this.isValidLogLevel(constructorLogLevel)) {

@@ -774,3 +795,5 @@ this.logLevel = this.logLevelThresholds[constructorLogLevel];

setLogFormatter(logFormatter) {
this.logFormatter = logFormatter ?? new PowertoolsLogFormatter();
this.logFormatter =
logFormatter ??
new PowertoolsLogFormatter({ envVarsService: this.getEnvVarsService() });
}

@@ -799,4 +822,4 @@ /**

const { logLevel, serviceName, sampleRateValue, logFormatter, customConfigService, persistentLogAttributes, environment, } = options;
// order is important, EnvVarsService() is used by other methods
this.setEnvVarsService();
// order is important, it uses EnvVarsService()
this.setConsole();

@@ -803,0 +826,0 @@ this.setCustomConfigService(customConfigService);

@@ -0,1 +1,2 @@

import type { ConfigServiceInterface as ConfigServiceBaseInterface } from '@aws-lambda-powertools/commons/types';
/**

@@ -8,10 +9,15 @@ * Interface ConfigServiceInterface

*/
interface ConfigServiceInterface {
interface ConfigServiceInterface extends ConfigServiceBaseInterface {
/**
* It returns the value of an environment variable that has given name.
* It returns the value of the `AWS_LAMBDA_LOG_LEVEL` environment variable.
*
* @param {string} name
* The `AWS_LAMBDA_LOG_LEVEL` environment variable is set by AWS Lambda when configuring
* the function's log level using the Advanced Logging Controls feature. This value always
* takes precedence over other means of configuring the log level.
*
* @note we need to map the `FATAL` log level to `CRITICAL`, see {@link https://docs.aws.amazon.com/lambda/latest/dg/configuration-logging.html#configuration-logging-log-levels AWS Lambda Log Levels}.
*
* @returns {string}
*/
get(name: string): string;
getAwsLogLevel(): string;
/**

@@ -30,4 +36,8 @@ * It returns the value of the ENVIRONMENT environment variable.

/**
* It returns the value of the LOG_LEVEL environment variable.
* It returns the value of the `POWERTOOLS_LOG_LEVEL, or `LOG_LEVEL` (legacy) environment variables
* when the first one is not set.
*
* @note The `LOG_LEVEL` environment variable is considered legacy and will be removed in a future release.
* @note The `AWS_LAMBDA_LOG_LEVEL` environment variable always takes precedence over the ones above.
*
* @returns {string}

@@ -42,23 +52,4 @@ */

getSampleRateValue(): number | undefined;
/**
* It returns the value of the POWERTOOLS_SERVICE_NAME environment variable.
*
* @returns {string}
*/
getServiceName(): string;
/**
* It returns the value of the POWERTOOLS_DEV environment variable.
*
* @returns {boolean}
*/
isDevMode(): boolean;
/**
* It returns true if the string value represents a boolean true value.
*
* @param {string} value
* @returns boolean
*/
isValueTrue(value: string): boolean;
}
export type { ConfigServiceInterface };
//# sourceMappingURL=ConfigServiceInterface.d.ts.map

@@ -0,1 +1,2 @@

import type { EnvironmentVariablesService } from '../config/EnvironmentVariablesService.js';
import type { LogItem } from '../formatter/LogItem.js';

@@ -99,2 +100,9 @@ import type { UnformattedAttributes } from './Logger.js';

}
type LogFormatterOptions = {
/**
* EnvironmentVariablesService instance.
* If set, it gives the LogFormatter access to environment variables.
*/
envVarsService?: EnvironmentVariablesService;
};
/**

@@ -134,3 +142,3 @@ * @interface

}
export type { LogAttributesWithMessage, LogAttributeValue, Environment, LogLevelThresholds, LogAttributes, LogLevel, PowertoolsLog, LogItemInterface, LogFormatterInterface, };
export type { LogAttributesWithMessage, LogAttributeValue, Environment, LogLevelThresholds, LogAttributes, LogLevel, PowertoolsLog, LogItemInterface, LogFormatterOptions, LogFormatterInterface, };
//# sourceMappingURL=Log.d.ts.map
{
"name": "@aws-lambda-powertools/logger",
"version": "2.0.0-alpha.1",
"version": "2.0.0-alpha.2",
"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.1",
"@aws-lambda-powertools/commons": "^2.0.0-alpha.2",
"lodash.merge": "^4.6.2"

@@ -31,0 +31,0 @@ },

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc