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
3
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.8.0 to 2.9.0

6

lib/cjs/Logger.d.ts

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

/**
* 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).
*/
private readonly logLevelThresholds;
/**
* Persistent log attributes that will be logged in all log items.

@@ -108,0 +102,0 @@ */

55

lib/cjs/Logger.js

@@ -106,18 +106,4 @@ "use strict";

*/
logLevel = 12;
logLevel = constants_js_1.LogLevelThreshold.INFO;
/**
* 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 = {
TRACE: 6,
DEBUG: 8,
INFO: 12,
WARN: 16,
ERROR: 20,
CRITICAL: 24,
SILENT: 28,
};
/**
* Persistent log attributes that will be logged in all log items.

@@ -157,3 +143,3 @@ */

*/
#initialLogLevel = this.logLevelThresholds.INFO;
#initialLogLevel = constants_js_1.LogLevelThreshold.INFO;
/**

@@ -267,3 +253,3 @@ * Replacer function used to serialize the log items.

critical(input, ...extraInput) {
this.processLogItem(this.logLevelThresholds.CRITICAL, input, extraInput);
this.processLogItem(constants_js_1.LogLevelThreshold.CRITICAL, input, extraInput);
}

@@ -277,3 +263,3 @@ /**

debug(input, ...extraInput) {
this.processLogItem(this.logLevelThresholds.DEBUG, input, extraInput);
this.processLogItem(constants_js_1.LogLevelThreshold.DEBUG, input, extraInput);
}

@@ -287,3 +273,3 @@ /**

error(input, ...extraInput) {
this.processLogItem(this.logLevelThresholds.ERROR, input, extraInput);
this.processLogItem(constants_js_1.LogLevelThreshold.ERROR, input, extraInput);
}

@@ -320,3 +306,3 @@ /**

info(input, ...extraInput) {
this.processLogItem(this.logLevelThresholds.INFO, input, extraInput);
this.processLogItem(constants_js_1.LogLevelThreshold.INFO, input, extraInput);
}

@@ -374,8 +360,7 @@ /**

*/
/* istanbul ignore next */
static injectLambdaContextAfterOrOnError(logger, _persistentAttributes, options) {
/* v8 ignore start */ static injectLambdaContextAfterOrOnError(logger, _persistentAttributes, options) {
if (options && (options.clearState || options?.resetKeys)) {
logger.resetKeys();
}
}
} /* v8 ignore stop */
/**

@@ -504,3 +489,3 @@ * @deprecated - This method is deprecated and will be removed in the next major version.

if (this.isValidLogLevel(logLevel)) {
this.logLevel = this.logLevelThresholds[logLevel];
this.logLevel = constants_js_1.LogLevelThreshold[logLevel];
}

@@ -540,3 +525,3 @@ else {

trace(input, ...extraInput) {
this.processLogItem(this.logLevelThresholds.TRACE, input, extraInput);
this.processLogItem(constants_js_1.LogLevelThreshold.TRACE, input, extraInput);
}

@@ -550,3 +535,3 @@ /**

warn(input, ...extraInput) {
this.processLogItem(this.logLevelThresholds.WARN, input, extraInput);
this.processLogItem(constants_js_1.LogLevelThreshold.WARN, input, extraInput);
}

@@ -619,5 +604,5 @@ /**

if (this.isValidLogLevel(awsLogLevel)) {
this.logLevel = this.logLevelThresholds[awsLogLevel];
this.logLevel = constants_js_1.LogLevelThreshold[awsLogLevel];
if (this.isValidLogLevel(selectedLogLevel) &&
this.logLevel > this.logLevelThresholds[selectedLogLevel]) {
this.logLevel > constants_js_1.LogLevelThreshold[selectedLogLevel]) {
this.warn(`Current log level (${selectedLogLevel}) does not match AWS Lambda Advanced Logging Controls minimum log level (${awsLogLevel}). This can lead to data loss, consider adjusting them.`);

@@ -713,3 +698,3 @@ }

let found;
for (const [key, value] of Object.entries(this.logLevelThresholds)) {
for (const [key, value] of Object.entries(constants_js_1.LogLevelThreshold)) {
if (value === logLevel) {

@@ -735,3 +720,3 @@ found = key;

isValidLogLevel(logLevel) {
return typeof logLevel === 'string' && logLevel in this.logLevelThresholds;
return typeof logLevel === 'string' && logLevel in constants_js_1.LogLevelThreshold;
}

@@ -756,3 +741,3 @@ /**

log.prepareForPrint();
const consoleMethod = logLevel === this.logLevelThresholds.CRITICAL
const consoleMethod = logLevel === constants_js_1.LogLevelThreshold.CRITICAL
? 'error'

@@ -827,3 +812,3 @@ : this.getLogLevelNameFromNumber(logLevel).toLowerCase();

if (this.isValidLogLevel(constructorLogLevel)) {
this.logLevel = this.logLevelThresholds[constructorLogLevel];
this.logLevel = constants_js_1.LogLevelThreshold[constructorLogLevel];
this.#initialLogLevel = this.logLevel;

@@ -836,3 +821,3 @@ return;

if (this.isValidLogLevel(customConfigValue)) {
this.logLevel = this.logLevelThresholds[customConfigValue];
this.logLevel = constants_js_1.LogLevelThreshold[customConfigValue];
this.#initialLogLevel = this.logLevel;

@@ -843,3 +828,3 @@ return;

if (this.isValidLogLevel(envVarsValue)) {
this.logLevel = this.logLevelThresholds[envVarsValue];
this.logLevel = constants_js_1.LogLevelThreshold[envVarsValue];
this.#initialLogLevel = this.logLevel;

@@ -866,3 +851,3 @@ return;

this.powertoolsLogData.sampleRateValue = value;
if (this.logLevel > this.logLevelThresholds.DEBUG &&
if (this.logLevel > constants_js_1.LogLevelThreshold.DEBUG &&
value &&

@@ -869,0 +854,0 @@ (0, node_crypto_1.randomInt)(0, 100) / 100 <= value) {

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

export type { Environment, LogLevelThresholds, LogAttributes, LogLevel, LogItemMessage, LogItemExtraInput, ConstructorOptions, InjectLambdaContextOptions, CustomJsonReplacerFn, LoggerInterface, } from './Logger.js';
export type { Environment, LogAttributes, LogLevel, LogItemMessage, LogItemExtraInput, ConstructorOptions, InjectLambdaContextOptions, CustomJsonReplacerFn, LoggerInterface, } from './Logger.js';
export type { UnformattedAttributes } from './logKeys.js';
//# sourceMappingURL=index.d.ts.map

@@ -15,10 +15,2 @@ import type { HandlerMethodDecorator } from '@aws-lambda-powertools/commons/types';

/**
* Type definition for the log level thresholds.
*
* Each log level has a corresponding number that represents its severity.
*/
type LogLevelThresholds = {
[key in Uppercase<LogLevel>]: number;
};
/**
* Type definition for a function that logs messages at different levels to the console.

@@ -190,3 +182,3 @@ */

};
export type { Environment, LogLevelThresholds, LogAttributes, LogLevel, LogFunction, LoggerInterface, LogItemMessage, LogItemExtraInput, ConstructorOptions, InjectLambdaContextOptions, CustomJsonReplacerFn, };
export type { Environment, LogAttributes, LogLevel, LogFunction, LoggerInterface, LogItemMessage, LogItemExtraInput, ConstructorOptions, InjectLambdaContextOptions, CustomJsonReplacerFn, };
//# sourceMappingURL=Logger.d.ts.map

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

/**
* 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).
*/
private readonly logLevelThresholds;
/**
* Persistent log attributes that will be logged in all log items.

@@ -108,0 +102,0 @@ */

@@ -6,3 +6,3 @@ import { Console } from 'node:console';

import { EnvironmentVariablesService } from './config/EnvironmentVariablesService.js';
import { LogJsonIndent } from './constants.js';
import { LogJsonIndent, LogLevelThreshold } from './constants.js';
import { PowertoolsLogFormatter } from './formatter/PowertoolsLogFormatter.js';

@@ -101,18 +101,4 @@ /**

*/
logLevel = 12;
logLevel = LogLevelThreshold.INFO;
/**
* 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 = {
TRACE: 6,
DEBUG: 8,
INFO: 12,
WARN: 16,
ERROR: 20,
CRITICAL: 24,
SILENT: 28,
};
/**
* Persistent log attributes that will be logged in all log items.

@@ -152,3 +138,3 @@ */

*/
#initialLogLevel = this.logLevelThresholds.INFO;
#initialLogLevel = LogLevelThreshold.INFO;
/**

@@ -262,3 +248,3 @@ * Replacer function used to serialize the log items.

critical(input, ...extraInput) {
this.processLogItem(this.logLevelThresholds.CRITICAL, input, extraInput);
this.processLogItem(LogLevelThreshold.CRITICAL, input, extraInput);
}

@@ -272,3 +258,3 @@ /**

debug(input, ...extraInput) {
this.processLogItem(this.logLevelThresholds.DEBUG, input, extraInput);
this.processLogItem(LogLevelThreshold.DEBUG, input, extraInput);
}

@@ -282,3 +268,3 @@ /**

error(input, ...extraInput) {
this.processLogItem(this.logLevelThresholds.ERROR, input, extraInput);
this.processLogItem(LogLevelThreshold.ERROR, input, extraInput);
}

@@ -315,3 +301,3 @@ /**

info(input, ...extraInput) {
this.processLogItem(this.logLevelThresholds.INFO, input, extraInput);
this.processLogItem(LogLevelThreshold.INFO, input, extraInput);
}

@@ -369,8 +355,7 @@ /**

*/
/* istanbul ignore next */
static injectLambdaContextAfterOrOnError(logger, _persistentAttributes, options) {
/* v8 ignore start */ static injectLambdaContextAfterOrOnError(logger, _persistentAttributes, options) {
if (options && (options.clearState || options?.resetKeys)) {
logger.resetKeys();
}
}
} /* v8 ignore stop */
/**

@@ -499,3 +484,3 @@ * @deprecated - This method is deprecated and will be removed in the next major version.

if (this.isValidLogLevel(logLevel)) {
this.logLevel = this.logLevelThresholds[logLevel];
this.logLevel = LogLevelThreshold[logLevel];
}

@@ -535,3 +520,3 @@ else {

trace(input, ...extraInput) {
this.processLogItem(this.logLevelThresholds.TRACE, input, extraInput);
this.processLogItem(LogLevelThreshold.TRACE, input, extraInput);
}

@@ -545,3 +530,3 @@ /**

warn(input, ...extraInput) {
this.processLogItem(this.logLevelThresholds.WARN, input, extraInput);
this.processLogItem(LogLevelThreshold.WARN, input, extraInput);
}

@@ -614,5 +599,5 @@ /**

if (this.isValidLogLevel(awsLogLevel)) {
this.logLevel = this.logLevelThresholds[awsLogLevel];
this.logLevel = LogLevelThreshold[awsLogLevel];
if (this.isValidLogLevel(selectedLogLevel) &&
this.logLevel > this.logLevelThresholds[selectedLogLevel]) {
this.logLevel > LogLevelThreshold[selectedLogLevel]) {
this.warn(`Current log level (${selectedLogLevel}) does not match AWS Lambda Advanced Logging Controls minimum log level (${awsLogLevel}). This can lead to data loss, consider adjusting them.`);

@@ -708,3 +693,3 @@ }

let found;
for (const [key, value] of Object.entries(this.logLevelThresholds)) {
for (const [key, value] of Object.entries(LogLevelThreshold)) {
if (value === logLevel) {

@@ -730,3 +715,3 @@ found = key;

isValidLogLevel(logLevel) {
return typeof logLevel === 'string' && logLevel in this.logLevelThresholds;
return typeof logLevel === 'string' && logLevel in LogLevelThreshold;
}

@@ -751,3 +736,3 @@ /**

log.prepareForPrint();
const consoleMethod = logLevel === this.logLevelThresholds.CRITICAL
const consoleMethod = logLevel === LogLevelThreshold.CRITICAL
? 'error'

@@ -822,3 +807,3 @@ : this.getLogLevelNameFromNumber(logLevel).toLowerCase();

if (this.isValidLogLevel(constructorLogLevel)) {
this.logLevel = this.logLevelThresholds[constructorLogLevel];
this.logLevel = LogLevelThreshold[constructorLogLevel];
this.#initialLogLevel = this.logLevel;

@@ -831,3 +816,3 @@ return;

if (this.isValidLogLevel(customConfigValue)) {
this.logLevel = this.logLevelThresholds[customConfigValue];
this.logLevel = LogLevelThreshold[customConfigValue];
this.#initialLogLevel = this.logLevel;

@@ -838,3 +823,3 @@ return;

if (this.isValidLogLevel(envVarsValue)) {
this.logLevel = this.logLevelThresholds[envVarsValue];
this.logLevel = LogLevelThreshold[envVarsValue];
this.#initialLogLevel = this.logLevel;

@@ -861,3 +846,3 @@ return;

this.powertoolsLogData.sampleRateValue = value;
if (this.logLevel > this.logLevelThresholds.DEBUG &&
if (this.logLevel > LogLevelThreshold.DEBUG &&
value &&

@@ -864,0 +849,0 @@ randomInt(0, 100) / 100 <= value) {

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

export type { Environment, LogLevelThresholds, LogAttributes, LogLevel, LogItemMessage, LogItemExtraInput, ConstructorOptions, InjectLambdaContextOptions, CustomJsonReplacerFn, LoggerInterface, } from './Logger.js';
export type { Environment, LogAttributes, LogLevel, LogItemMessage, LogItemExtraInput, ConstructorOptions, InjectLambdaContextOptions, CustomJsonReplacerFn, LoggerInterface, } from './Logger.js';
export type { UnformattedAttributes } from './logKeys.js';
//# sourceMappingURL=index.d.ts.map

@@ -15,10 +15,2 @@ import type { HandlerMethodDecorator } from '@aws-lambda-powertools/commons/types';

/**
* Type definition for the log level thresholds.
*
* Each log level has a corresponding number that represents its severity.
*/
type LogLevelThresholds = {
[key in Uppercase<LogLevel>]: number;
};
/**
* Type definition for a function that logs messages at different levels to the console.

@@ -190,3 +182,3 @@ */

};
export type { Environment, LogLevelThresholds, LogAttributes, LogLevel, LogFunction, LoggerInterface, LogItemMessage, LogItemExtraInput, ConstructorOptions, InjectLambdaContextOptions, CustomJsonReplacerFn, };
export type { Environment, LogAttributes, LogLevel, LogFunction, LoggerInterface, LogItemMessage, LogItemExtraInput, ConstructorOptions, InjectLambdaContextOptions, CustomJsonReplacerFn, };
//# sourceMappingURL=Logger.d.ts.map
{
"name": "@aws-lambda-powertools/logger",
"version": "2.8.0",
"version": "2.9.0",
"description": "The logging package for the Powertools for AWS Lambda (TypeScript) library",

@@ -28,3 +28,3 @@ "author": {

"dependencies": {
"@aws-lambda-powertools/commons": "^2.8.0",
"@aws-lambda-powertools/commons": "^2.9.0",
"lodash.merge": "^4.6.2"

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

@@ -244,2 +244,3 @@ # Powertools for AWS Lambda (TypeScript) <!-- omit in toc -->

- [Elva](https://elva-group.com)
- [Flyweight](https://flyweight.io/)
- [globaldatanet](https://globaldatanet.com/)

@@ -246,0 +247,0 @@ - [Hashnode](https://hashnode.com/)

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