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

The logging package for the Powertools for AWS Lambda (TypeScript) library

  • 2.10.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
266K
decreased by-11.23%
Maintainers
3
Weekly downloads
 
Created

What is @aws-lambda-powertools/logger?

@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.

What are @aws-lambda-powertools/logger's main functionalities?

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' };
};

Other packages similar to @aws-lambda-powertools/logger

Keywords

FAQs

Package last updated on 22 Oct 2024

Did you know?

Socket

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.

Install

Related posts

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