Security News
Research
Supply Chain Attack on Rspack npm Packages Injects Cryptojacking Malware
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
@aws-lambda-powertools/logger
Advanced tools
The logging package for the AWS Lambda Powertools for TypeScript library
@aws-lambda-powertools/logger is a structured logging utility designed for AWS Lambda functions. It simplifies the process of creating consistent and meaningful logs, which can be crucial for debugging and monitoring serverless applications.
Basic Logging
This feature allows you to log basic information. The logger.info method is used to log informational messages.
const { Logger } = require('@aws-lambda-powertools/logger');
const logger = new Logger();
exports.handler = async (event) => {
logger.info('This is an info log');
return { statusCode: 200, body: 'Hello World' };
};
Structured Logging
Structured logging allows you to add context to your logs, making them more useful for debugging and monitoring. You can add persistent attributes that will be included in every log entry.
const { Logger } = require('@aws-lambda-powertools/logger');
const logger = new Logger({
persistentLogAttributes: {
service: 'my-service',
environment: 'production'
}
});
exports.handler = async (event) => {
logger.info('This is a structured log', { userId: '12345' });
return { statusCode: 200, body: 'Hello World' };
};
Error Logging
This feature allows you to log errors with additional context. The logger.error method is used to log error messages.
const { Logger } = require('@aws-lambda-powertools/logger');
const logger = new Logger();
exports.handler = async (event) => {
try {
throw new Error('Something went wrong');
} catch (error) {
logger.error('An error occurred', { error });
}
return { statusCode: 500, body: 'Internal Server Error' };
};
Winston is a versatile logging library for Node.js that supports multiple transports (e.g., console, file, HTTP). It offers more flexibility and customization options compared to @aws-lambda-powertools/logger but requires more setup.
Bunyan is another structured logging library for Node.js. It provides a JSON-based logging format and includes features like log levels and serializers. It is similar to @aws-lambda-powertools/logger in terms of structured logging but is more general-purpose.
Pino is a fast JSON logger for Node.js applications. It is designed for high performance and low overhead. While it offers similar structured logging capabilities, it is more focused on performance compared to @aws-lambda-powertools/logger.
⚠️ WARNING: Do not use this library in production ⚠️ |
---|
AWS Lambda Powertools for TypeScript is currently released as a beta developer preview and is intended strictly for feedback purposes only. This version is not stable, and significant breaking changes might incur as part of the upcoming production-ready release. |
A suite of TypeScript utilities for AWS Lambda functions to ease adopting best practices such as tracing, structured logging, custom metrics, and more. (AWS Lambda Powertools for Python and AWS Lambda Powertools for Java are also available).
📜 Documentation | NPM | Roadmap | Examples
An AWS Developer Acceleration (DevAx) initiative by Specialist Solution Architects | aws-devax-open-source@amazon.com
Find the complete project's documentation here.
The AWS Lambda Powertools for TypeScript utilities follow a modular approach, similar to the official AWS SDK v3 for JavaScript.
Each TypeScript utility is installed as standalone NPM package.
👉 Installation guide for the Tracer utility
👉 Installation guide for the Logger utility
👉 Installation guide for the Metrics utility
#lambda-powertools
- Invite, if you don't have an accountThis library is licensed under the MIT-0 License. See the LICENSE file.
FAQs
The logging package for the Powertools for AWS Lambda (TypeScript) library
The npm package @aws-lambda-powertools/logger receives a total of 256,241 weekly downloads. As such, @aws-lambda-powertools/logger popularity was classified as popular.
We found that @aws-lambda-powertools/logger demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.
Security News
Sonar’s acquisition of Tidelift highlights a growing industry shift toward sustainable open source funding, addressing maintainer burnout and critical software dependencies.